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

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

Issue 11411271: Remove support for interfaces. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 RawField* LookupField(const String& name) const; 672 RawField* LookupField(const String& name) const;
673 673
674 RawLibraryPrefix* LookupLibraryPrefix(const String& name) const; 674 RawLibraryPrefix* LookupLibraryPrefix(const String& name) const;
675 675
676 void InsertCanonicalConstant(intptr_t index, const Instance& constant) const; 676 void InsertCanonicalConstant(intptr_t index, const Instance& constant) const;
677 677
678 static intptr_t InstanceSize() { 678 static intptr_t InstanceSize() {
679 return RoundedAllocationSize(sizeof(RawClass)); 679 return RoundedAllocationSize(sizeof(RawClass));
680 } 680 }
681 681
682 bool is_interface() const {
683 return InterfaceBit::decode(raw_ptr()->state_bits_);
684 }
685 void set_is_interface() const;
686
687 bool is_implemented() const { 682 bool is_implemented() const {
688 return ImplementedBit::decode(raw_ptr()->state_bits_); 683 return ImplementedBit::decode(raw_ptr()->state_bits_);
689 } 684 }
690 void set_is_implemented() const; 685 void set_is_implemented() const;
691 686
692 bool is_abstract() const { 687 bool is_abstract() const {
693 return AbstractBit::decode(raw_ptr()->state_bits_); 688 return AbstractBit::decode(raw_ptr()->state_bits_);
694 } 689 }
695 void set_is_abstract() const; 690 void set_is_abstract() const;
696 691
(...skipping 28 matching lines...) Expand all
725 720
726 RawArray* constants() const; 721 RawArray* constants() const;
727 722
728 void Finalize() const; 723 void Finalize() const;
729 724
730 const char* ApplyPatch(const Class& patch) const; 725 const char* ApplyPatch(const Class& patch) const;
731 726
732 // Allocate a class used for VM internal objects. 727 // Allocate a class used for VM internal objects.
733 template <class FakeObject> static RawClass* New(); 728 template <class FakeObject> static RawClass* New();
734 729
735 // Allocate instance classes and interfaces. 730 // Allocate instance classes.
736 static RawClass* New(const String& name, 731 static RawClass* New(const String& name,
737 const Script& script, 732 const Script& script,
738 intptr_t token_pos); 733 intptr_t token_pos);
739 static RawClass* NewInterface(const String& name,
740 const Script& script,
741 intptr_t token_pos);
742 static RawClass* NewNativeWrapper(const Library& library, 734 static RawClass* NewNativeWrapper(const Library& library,
743 const String& name, 735 const String& name,
744 int num_fields); 736 int num_fields);
745 737
746 // Allocate the raw string classes. 738 // Allocate the raw string classes.
747 static RawClass* NewStringClass(intptr_t class_id); 739 static RawClass* NewStringClass(intptr_t class_id);
748 740
749 // Allocate a class representing a function signature described by 741 // Allocate a class representing a function signature described by
750 // signature_function, which must be a closure function or a signature 742 // signature_function, which must be a closure function or a signature
751 // function. 743 // function.
752 // The class may be type parameterized unless the signature_function is in a 744 // The class may be type parameterized unless the signature_function is in a
753 // static scope. In that case, the type parameters are copied from the owner 745 // static scope. In that case, the type parameters are copied from the owner
754 // class of signature_function. 746 // class of signature_function.
755 static RawClass* NewSignatureClass(const String& name, 747 static RawClass* NewSignatureClass(const String& name,
756 const Function& signature_function, 748 const Function& signature_function,
757 const Script& script); 749 const Script& script);
758 750
759 // Return a class object corresponding to the specified kind. If 751 // Return a class object corresponding to the specified kind. If
760 // a canonicalized version of it exists then that object is returned 752 // a canonicalized version of it exists then that object is returned
761 // otherwise a new object is allocated and returned. 753 // otherwise a new object is allocated and returned.
762 static RawClass* GetClass(intptr_t class_id, bool is_signature_class); 754 static RawClass* GetClass(intptr_t class_id, bool is_signature_class);
763 755
764 private: 756 private:
765 enum { 757 enum {
766 kConstBit = 1, 758 kConstBit = 1,
767 kInterfaceBit = 2, 759 kImplementedBit = 2,
768 kImplementedBit = 3, 760 kAbstractBit = 3,
769 kAbstractBit = 4, 761 kStateTagBit = 4,
770 kStateTagBit = 5,
771 kStateTagSize = 2, 762 kStateTagSize = 2,
772 }; 763 };
773 class ConstBit : public BitField<bool, kConstBit, 1> {}; 764 class ConstBit : public BitField<bool, kConstBit, 1> {};
774 class InterfaceBit : public BitField<bool, kInterfaceBit, 1> {};
775 class ImplementedBit : public BitField<bool, kImplementedBit, 1> {}; 765 class ImplementedBit : public BitField<bool, kImplementedBit, 1> {};
776 class AbstractBit : public BitField<bool, kAbstractBit, 1> {}; 766 class AbstractBit : public BitField<bool, kAbstractBit, 1> {};
777 class StateBits : public BitField<RawClass::ClassState, 767 class StateBits : public BitField<RawClass::ClassState,
778 kStateTagBit, kStateTagSize> {}; // NOLINT 768 kStateTagBit, kStateTagSize> {}; // NOLINT
779 769
780 void set_name(const String& value) const; 770 void set_name(const String& value) const;
781 void set_token_pos(intptr_t value) const; 771 void set_token_pos(intptr_t value) const;
782 void set_signature_function(const Function& value) const; 772 void set_signature_function(const Function& value) const;
783 void set_signature_type(const AbstractType& value) const; 773 void set_signature_type(const AbstractType& value) const;
784 void set_class_state(RawClass::ClassState state) const; 774 void set_class_state(RawClass::ClassState state) const;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 842
853 // AbstractTypeArguments is an abstract superclass. 843 // AbstractTypeArguments is an abstract superclass.
854 // Subclasses of AbstractTypeArguments are TypeArguments and 844 // Subclasses of AbstractTypeArguments are TypeArguments and
855 // InstantiatedTypeArguments. 845 // InstantiatedTypeArguments.
856 class AbstractTypeArguments : public Object { 846 class AbstractTypeArguments : public Object {
857 public: 847 public:
858 // Returns true if both arguments represent vectors of equal types. 848 // Returns true if both arguments represent vectors of equal types.
859 static bool AreEqual(const AbstractTypeArguments& arguments, 849 static bool AreEqual(const AbstractTypeArguments& arguments,
860 const AbstractTypeArguments& other_arguments); 850 const AbstractTypeArguments& other_arguments);
861 851
862 // Returns true if both arguments represent vectors of possibly still
863 // unresolved identical types.
864 static bool AreIdentical(const AbstractTypeArguments& arguments,
865 const AbstractTypeArguments& other_arguments,
866 bool check_type_parameter_bounds);
867
868 // Return 'this' if this type argument vector is instantiated, i.e. if it does 852 // Return 'this' if this type argument vector is instantiated, i.e. if it does
869 // not refer to type parameters. Otherwise, return a new type argument vector 853 // not refer to type parameters. Otherwise, return a new type argument vector
870 // where each reference to a type parameter is replaced with the corresponding 854 // where each reference to a type parameter is replaced with the corresponding
871 // type of the instantiator type argument vector. 855 // type of the instantiator type argument vector.
872 virtual RawAbstractTypeArguments* InstantiateFrom( 856 virtual RawAbstractTypeArguments* InstantiateFrom(
873 const AbstractTypeArguments& instantiator_type_arguments) const; 857 const AbstractTypeArguments& instantiator_type_arguments) const;
874 858
875 // Do not canonicalize InstantiatedTypeArguments or NULL objects 859 // Do not canonicalize InstantiatedTypeArguments or NULL objects
876 virtual RawAbstractTypeArguments* Canonicalize() const { return this->raw(); } 860 virtual RawAbstractTypeArguments* Canonicalize() const { return this->raw(); }
877 861
(...skipping 16 matching lines...) Expand all
894 878
895 // Check if this type argument vector would consist solely of DynamicType if 879 // Check if this type argument vector would consist solely of DynamicType if
896 // it was instantiated from a raw (null) instantiator, i.e. consider each type 880 // it was instantiated from a raw (null) instantiator, i.e. consider each type
897 // parameter as it would be first instantiated from a vector of dynamic types. 881 // parameter as it would be first instantiated from a vector of dynamic types.
898 // Consider only a prefix of length 'len'. 882 // Consider only a prefix of length 'len'.
899 bool IsRawInstantiatedRaw(intptr_t len) const { 883 bool IsRawInstantiatedRaw(intptr_t len) const {
900 return IsDynamicTypes(true, len); 884 return IsDynamicTypes(true, len);
901 } 885 }
902 886
903 // Check that this type argument vector is within the declared bounds of the 887 // Check that this type argument vector is within the declared bounds of the
904 // given class or interface. If not, set malformed_error (if not yet set). 888 // given class. If not, set malformed_error (if not yet set).
905 bool IsWithinBoundsOf(const Class& cls, 889 bool IsWithinBoundsOf(const Class& cls,
906 const AbstractTypeArguments& bounds_instantiator, 890 const AbstractTypeArguments& bounds_instantiator,
907 Error* malformed_error) const; 891 Error* malformed_error) const;
908 892
909 // Check the subtype relationship, considering only a prefix of length 'len'. 893 // Check the subtype relationship, considering only a prefix of length 'len'.
910 bool IsSubtypeOf(const AbstractTypeArguments& other, 894 bool IsSubtypeOf(const AbstractTypeArguments& other,
911 intptr_t len, 895 intptr_t len,
912 Error* malformed_error) const { 896 Error* malformed_error) const {
913 return TypeTest(kIsSubtypeOf, other, len, malformed_error); 897 return TypeTest(kIsSubtypeOf, other, len, malformed_error);
914 } 898 }
(...skipping 2260 matching lines...) Expand 10 before | Expand all | Expand 10 after
3175 virtual RawError* malformed_error() const; 3159 virtual RawError* malformed_error() const;
3176 virtual void set_malformed_error(const Error& value) const; 3160 virtual void set_malformed_error(const Error& value) const;
3177 virtual bool IsResolved() const; 3161 virtual bool IsResolved() const;
3178 virtual bool HasResolvedTypeClass() const; 3162 virtual bool HasResolvedTypeClass() const;
3179 virtual RawClass* type_class() const; 3163 virtual RawClass* type_class() const;
3180 virtual RawUnresolvedClass* unresolved_class() const; 3164 virtual RawUnresolvedClass* unresolved_class() const;
3181 virtual RawAbstractTypeArguments* arguments() const; 3165 virtual RawAbstractTypeArguments* arguments() const;
3182 virtual intptr_t token_pos() const; 3166 virtual intptr_t token_pos() const;
3183 virtual bool IsInstantiated() const; 3167 virtual bool IsInstantiated() const;
3184 virtual bool Equals(const Instance& other) const; 3168 virtual bool Equals(const Instance& other) const;
3185 virtual bool IsIdentical(const AbstractType& other,
3186 bool check_type_parameter_bound) const;
3187 3169
3188 // Instantiate this type using the given type argument vector. 3170 // Instantiate this type using the given type argument vector.
3189 // Return a new type, or return 'this' if it is already instantiated. 3171 // Return a new type, or return 'this' if it is already instantiated.
3190 virtual RawAbstractType* InstantiateFrom( 3172 virtual RawAbstractType* InstantiateFrom(
3191 const AbstractTypeArguments& instantiator_type_arguments) const; 3173 const AbstractTypeArguments& instantiator_type_arguments) const;
3192 3174
3193 // Return the canonical version of this type. 3175 // Return the canonical version of this type.
3194 virtual RawAbstractType* Canonicalize() const; 3176 virtual RawAbstractType* Canonicalize() const;
3195 3177
3196 // The name of this type, including the names of its type arguments, if any. 3178 // The name of this type, including the names of its type arguments, if any.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3239 3221
3240 // Check if this type represents the 'num' type. 3222 // Check if this type represents the 'num' type.
3241 bool IsNumberType() const; 3223 bool IsNumberType() const;
3242 3224
3243 // Check if this type represents the 'String' type. 3225 // Check if this type represents the 'String' type.
3244 bool IsStringType() const; 3226 bool IsStringType() const;
3245 3227
3246 // Check if this type represents the 'Function' type. 3228 // Check if this type represents the 'Function' type.
3247 bool IsFunctionType() const; 3229 bool IsFunctionType() const;
3248 3230
3249 // Check if this type is an interface type.
3250 bool IsInterfaceType() const {
3251 if (!HasResolvedTypeClass()) {
3252 return false;
3253 }
3254 const Class& cls = Class::Handle(type_class());
3255 return !cls.IsNull() && cls.is_interface();
3256 }
3257
3258 // Check the subtype relationship. 3231 // Check the subtype relationship.
3259 bool IsSubtypeOf(const AbstractType& other, Error* malformed_error) const { 3232 bool IsSubtypeOf(const AbstractType& other, Error* malformed_error) const {
3260 return TypeTest(kIsSubtypeOf, other, malformed_error); 3233 return TypeTest(kIsSubtypeOf, other, malformed_error);
3261 } 3234 }
3262 3235
3263 // Check the 'more specific' relationship. 3236 // Check the 'more specific' relationship.
3264 bool IsMoreSpecificThan(const AbstractType& other, 3237 bool IsMoreSpecificThan(const AbstractType& other,
3265 Error* malformed_error) const { 3238 Error* malformed_error) const {
3266 return TypeTest(kIsMoreSpecificThan, other, malformed_error); 3239 return TypeTest(kIsMoreSpecificThan, other, malformed_error);
3267 } 3240 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3314 virtual bool HasResolvedTypeClass() const; // Own type class resolved. 3287 virtual bool HasResolvedTypeClass() const; // Own type class resolved.
3315 virtual RawClass* type_class() const; 3288 virtual RawClass* type_class() const;
3316 void set_type_class(const Object& value) const; 3289 void set_type_class(const Object& value) const;
3317 virtual RawUnresolvedClass* unresolved_class() const; 3290 virtual RawUnresolvedClass* unresolved_class() const;
3318 RawString* TypeClassName() const; 3291 RawString* TypeClassName() const;
3319 virtual RawAbstractTypeArguments* arguments() const; 3292 virtual RawAbstractTypeArguments* arguments() const;
3320 void set_arguments(const AbstractTypeArguments& value) const; 3293 void set_arguments(const AbstractTypeArguments& value) const;
3321 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } 3294 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; }
3322 virtual bool IsInstantiated() const; 3295 virtual bool IsInstantiated() const;
3323 virtual bool Equals(const Instance& other) const; 3296 virtual bool Equals(const Instance& other) const;
3324 virtual bool IsIdentical(const AbstractType& other,
3325 bool check_type_parameter_bound) const;
3326 virtual RawAbstractType* InstantiateFrom( 3297 virtual RawAbstractType* InstantiateFrom(
3327 const AbstractTypeArguments& instantiator_type_arguments) const; 3298 const AbstractTypeArguments& instantiator_type_arguments) const;
3328 virtual RawAbstractType* Canonicalize() const; 3299 virtual RawAbstractType* Canonicalize() const;
3329 3300
3330 static intptr_t InstanceSize() { 3301 static intptr_t InstanceSize() {
3331 return RoundedAllocationSize(sizeof(RawType)); 3302 return RoundedAllocationSize(sizeof(RawType));
3332 } 3303 }
3333 3304
3334 // The type of the literal 'null'. 3305 // The type of the literal 'null'.
3335 static RawType* NullType(); 3306 static RawType* NullType();
(...skipping 15 matching lines...) Expand all
3351 3322
3352 // The 'Smi' type. 3323 // The 'Smi' type.
3353 static RawType* SmiType(); 3324 static RawType* SmiType();
3354 3325
3355 // The 'Mint' type. 3326 // The 'Mint' type.
3356 static RawType* MintType(); 3327 static RawType* MintType();
3357 3328
3358 // The 'double' type. 3329 // The 'double' type.
3359 static RawType* Double(); 3330 static RawType* Double();
3360 3331
3361 // The 'num' interface type. 3332 // The 'num' type.
3362 static RawType* Number(); 3333 static RawType* Number();
3363 3334
3364 // The 'String' type. 3335 // The 'String' type.
3365 static RawType* StringType(); 3336 static RawType* StringType();
3366 3337
3367 // The 'Array' type. 3338 // The 'Array' type.
3368 static RawType* ArrayType(); 3339 static RawType* ArrayType();
3369 3340
3370 // The 'Function' interface type. 3341 // The 'Function' type.
3371 static RawType* Function(); 3342 static RawType* Function();
3372 3343
3373 // The finalized type of the given non-parameterized class. 3344 // The finalized type of the given non-parameterized class.
3374 static RawType* NewNonParameterizedType(const Class& type_class); 3345 static RawType* NewNonParameterizedType(const Class& type_class);
3375 3346
3376 static RawType* New(const Object& clazz, 3347 static RawType* New(const Object& clazz,
3377 const AbstractTypeArguments& arguments, 3348 const AbstractTypeArguments& arguments,
3378 intptr_t token_pos, 3349 intptr_t token_pos,
3379 Heap::Space space = Heap::kOld); 3350 Heap::Space space = Heap::kOld);
3380 3351
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3414 return raw_ptr()->parameterized_class_; 3385 return raw_ptr()->parameterized_class_;
3415 } 3386 }
3416 RawString* name() const { return raw_ptr()->name_; } 3387 RawString* name() const { return raw_ptr()->name_; }
3417 intptr_t index() const { return raw_ptr()->index_; } 3388 intptr_t index() const { return raw_ptr()->index_; }
3418 void set_index(intptr_t value) const; 3389 void set_index(intptr_t value) const;
3419 RawAbstractType* bound() const { return raw_ptr()->bound_; } 3390 RawAbstractType* bound() const { return raw_ptr()->bound_; }
3420 void set_bound(const AbstractType& value) const; 3391 void set_bound(const AbstractType& value) const;
3421 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } 3392 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; }
3422 virtual bool IsInstantiated() const { return false; } 3393 virtual bool IsInstantiated() const { return false; }
3423 virtual bool Equals(const Instance& other) const; 3394 virtual bool Equals(const Instance& other) const;
3424 virtual bool IsIdentical(const AbstractType& other,
3425 bool check_type_parameter_bound) const;
3426 virtual RawAbstractType* InstantiateFrom( 3395 virtual RawAbstractType* InstantiateFrom(
3427 const AbstractTypeArguments& instantiator_type_arguments) const; 3396 const AbstractTypeArguments& instantiator_type_arguments) const;
3428 virtual RawAbstractType* Canonicalize() const { return raw(); } 3397 virtual RawAbstractType* Canonicalize() const { return raw(); }
3429 3398
3430 static intptr_t InstanceSize() { 3399 static intptr_t InstanceSize() {
3431 return RoundedAllocationSize(sizeof(RawTypeParameter)); 3400 return RoundedAllocationSize(sizeof(RawTypeParameter));
3432 } 3401 }
3433 3402
3434 static RawTypeParameter* New(const Class& parameterized_class, 3403 static RawTypeParameter* New(const Class& parameterized_class,
3435 intptr_t index, 3404 intptr_t index,
(...skipping 2557 matching lines...) Expand 10 before | Expand all | Expand 10 after
5993 if (this->CharAt(i) != str.CharAt(begin_index + i)) { 5962 if (this->CharAt(i) != str.CharAt(begin_index + i)) {
5994 return false; 5963 return false;
5995 } 5964 }
5996 } 5965 }
5997 return true; 5966 return true;
5998 } 5967 }
5999 5968
6000 } // namespace dart 5969 } // namespace dart
6001 5970
6002 #endif // VM_OBJECT_H_ 5971 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698