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

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

Issue 12473002: Complete implementation of bounds checking in the vm, by introducing a vm object (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 months 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
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 set_type_arguments_field_offset_in_words(value); 645 set_type_arguments_field_offset_in_words(value);
646 } 646 }
647 void set_type_arguments_field_offset_in_words(intptr_t value) const { 647 void set_type_arguments_field_offset_in_words(intptr_t value) const {
648 raw_ptr()->type_arguments_field_offset_in_words_ = value; 648 raw_ptr()->type_arguments_field_offset_in_words_ = value;
649 } 649 }
650 static intptr_t type_arguments_field_offset_in_words_offset() { 650 static intptr_t type_arguments_field_offset_in_words_offset() {
651 return OFFSET_OF(RawClass, type_arguments_field_offset_in_words_); 651 return OFFSET_OF(RawClass, type_arguments_field_offset_in_words_);
652 } 652 }
653 653
654 // The super type of this class, Object type if not explicitly specified. 654 // The super type of this class, Object type if not explicitly specified.
655 RawType* super_type() const { return raw_ptr()->super_type_; } 655 // Note that the super type may be bounded, as in this example:
656 void set_super_type(const Type& value) const; 656 // class C<T> extends S<T> { }; class S<T extends num> { };
657 RawAbstractType* super_type() const { return raw_ptr()->super_type_; }
658 void set_super_type(const AbstractType& value) const;
657 static intptr_t super_type_offset() { 659 static intptr_t super_type_offset() {
658 return OFFSET_OF(RawClass, super_type_); 660 return OFFSET_OF(RawClass, super_type_);
659 } 661 }
660 662
661 // Asserts that the class of the super type has been resolved. 663 // Asserts that the class of the super type has been resolved.
662 RawClass* SuperClass() const; 664 RawClass* SuperClass() const;
663 665
664 RawType* mixin() const { return raw_ptr()->mixin_; } 666 RawType* mixin() const { return raw_ptr()->mixin_; }
665 void set_mixin(const Type& value) const; 667 void set_mixin(const Type& value) const;
666 668
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 class AbstractTypeArguments : public Object { 946 class AbstractTypeArguments : public Object {
945 public: 947 public:
946 // Returns true if both arguments represent vectors of equal types. 948 // Returns true if both arguments represent vectors of equal types.
947 static bool AreEqual(const AbstractTypeArguments& arguments, 949 static bool AreEqual(const AbstractTypeArguments& arguments,
948 const AbstractTypeArguments& other_arguments); 950 const AbstractTypeArguments& other_arguments);
949 951
950 // Return 'this' if this type argument vector is instantiated, i.e. if it does 952 // Return 'this' if this type argument vector is instantiated, i.e. if it does
951 // not refer to type parameters. Otherwise, return a new type argument vector 953 // not refer to type parameters. Otherwise, return a new type argument vector
952 // where each reference to a type parameter is replaced with the corresponding 954 // where each reference to a type parameter is replaced with the corresponding
953 // type of the instantiator type argument vector. 955 // type of the instantiator type argument vector.
956 // If malformed_error is not NULL, it may be set to reflect a bound error.
954 virtual RawAbstractTypeArguments* InstantiateFrom( 957 virtual RawAbstractTypeArguments* InstantiateFrom(
955 const AbstractTypeArguments& instantiator_type_arguments) const; 958 const AbstractTypeArguments& instantiator_type_arguments,
959 Error* malformed_error) const;
956 960
957 // Do not canonicalize InstantiatedTypeArguments or NULL objects 961 // Do not canonicalize InstantiatedTypeArguments or NULL objects
958 virtual RawAbstractTypeArguments* Canonicalize() const { return this->raw(); } 962 virtual RawAbstractTypeArguments* Canonicalize() const { return this->raw(); }
959 963
960 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, Smi>". 964 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, Smi>".
961 virtual RawString* Name() const { 965 virtual RawString* Name() const {
962 return SubvectorName(0, Length(), kInternalName); 966 return SubvectorName(0, Length(), kInternalName);
963 } 967 }
964 968
965 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, int>". 969 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, int>".
966 // Names of internal classes are mapped to their public interfaces. 970 // Names of internal classes are mapped to their public interfaces.
967 virtual RawString* UserVisibleName() const { 971 virtual RawString* UserVisibleName() const {
968 return SubvectorName(0, Length(), kUserVisibleName); 972 return SubvectorName(0, Length(), kUserVisibleName);
969 } 973 }
970 974
971 // Check if this type argument vector consists solely of DynamicType, 975 // Check if this type argument vector consists solely of DynamicType,
972 // considering only a prefix of length 'len'. 976 // considering only a prefix of length 'len'.
973 bool IsRaw(intptr_t len) const { 977 bool IsRaw(intptr_t len) const {
974 return IsDynamicTypes(false, len); 978 return IsDynamicTypes(false, len);
975 } 979 }
976 980
977 // Check if this type argument vector would consist solely of DynamicType if 981 // Check if this type argument vector would consist solely of DynamicType if
978 // it was instantiated from a raw (null) instantiator, i.e. consider each type 982 // it was instantiated from a raw (null) instantiator, i.e. consider each type
979 // parameter as it would be first instantiated from a vector of dynamic types. 983 // parameter as it would be first instantiated from a vector of dynamic types.
980 // Consider only a prefix of length 'len'. 984 // Consider only a prefix of length 'len'.
981 bool IsRawInstantiatedRaw(intptr_t len) const { 985 bool IsRawInstantiatedRaw(intptr_t len) const {
982 return IsDynamicTypes(true, len); 986 return IsDynamicTypes(true, len);
983 } 987 }
984 988
985 // Check that this type argument vector is within the declared bounds of the
986 // given class. If not, set malformed_error (if not yet set).
987 bool IsWithinBoundsOf(const Class& cls,
988 const AbstractTypeArguments& bounds_instantiator,
989 Error* malformed_error) const;
990
991 // Check the subtype relationship, considering only a prefix of length 'len'. 989 // Check the subtype relationship, considering only a prefix of length 'len'.
992 bool IsSubtypeOf(const AbstractTypeArguments& other, 990 bool IsSubtypeOf(const AbstractTypeArguments& other,
993 intptr_t len, 991 intptr_t len,
994 Error* malformed_error) const { 992 Error* malformed_error) const {
995 return TypeTest(kIsSubtypeOf, other, len, malformed_error); 993 return TypeTest(kIsSubtypeOf, other, len, malformed_error);
996 } 994 }
997 995
998 // Check the 'more specific' relationship, considering only a prefix of 996 // Check the 'more specific' relationship, considering only a prefix of
999 // length 'len'. 997 // length 'len'.
1000 bool IsMoreSpecificThan(const AbstractTypeArguments& other, 998 bool IsMoreSpecificThan(const AbstractTypeArguments& other,
1001 intptr_t len, 999 intptr_t len,
1002 Error* malformed_error) const { 1000 Error* malformed_error) const {
1003 return TypeTest(kIsMoreSpecificThan, other, len, malformed_error); 1001 return TypeTest(kIsMoreSpecificThan, other, len, malformed_error);
1004 } 1002 }
1005 1003
1006 bool Equals(const AbstractTypeArguments& other) const; 1004 bool Equals(const AbstractTypeArguments& other) const;
1007 1005
1008 // UNREACHABLEs as AbstractTypeArguments is an abstract class. 1006 // UNREACHABLEs as AbstractTypeArguments is an abstract class.
1009 virtual intptr_t Length() const; 1007 virtual intptr_t Length() const;
1010 virtual RawAbstractType* TypeAt(intptr_t index) const; 1008 virtual RawAbstractType* TypeAt(intptr_t index) const;
1011 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; 1009 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const;
1012 virtual bool IsResolved() const; 1010 virtual bool IsResolved() const;
1013 virtual bool IsInstantiated() const; 1011 virtual bool IsInstantiated() const;
1014 virtual bool IsUninstantiatedIdentity() const; 1012 virtual bool IsUninstantiatedIdentity() const;
1013 virtual bool IsBounded() const;
1015 1014
1016 virtual intptr_t Hash() const; 1015 virtual intptr_t Hash() const;
1017 1016
1018 private: 1017 private:
1019 // Check if this type argument vector consists solely of DynamicType, 1018 // Check if this type argument vector consists solely of DynamicType,
1020 // considering only a prefix of length 'len'. 1019 // considering only a prefix of length 'len'.
1021 // If raw_instantiated is true, consider each type parameter to be first 1020 // If raw_instantiated is true, consider each type parameter to be first
1022 // instantiated from a vector of dynamic types. 1021 // instantiated from a vector of dynamic types.
1023 bool IsDynamicTypes(bool raw_instantiated, intptr_t len) const; 1022 bool IsDynamicTypes(bool raw_instantiated, intptr_t len) const;
1024 1023
(...skipping 22 matching lines...) Expand all
1047 public: 1046 public:
1048 virtual intptr_t Length() const; 1047 virtual intptr_t Length() const;
1049 virtual RawAbstractType* TypeAt(intptr_t index) const; 1048 virtual RawAbstractType* TypeAt(intptr_t index) const;
1050 static intptr_t type_at_offset(intptr_t index) { 1049 static intptr_t type_at_offset(intptr_t index) {
1051 return OFFSET_OF(RawTypeArguments, types_) + index * kWordSize; 1050 return OFFSET_OF(RawTypeArguments, types_) + index * kWordSize;
1052 } 1051 }
1053 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; 1052 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const;
1054 virtual bool IsResolved() const; 1053 virtual bool IsResolved() const;
1055 virtual bool IsInstantiated() const; 1054 virtual bool IsInstantiated() const;
1056 virtual bool IsUninstantiatedIdentity() const; 1055 virtual bool IsUninstantiatedIdentity() const;
1056 virtual bool IsBounded() const;
1057 // Canonicalize only if instantiated, otherwise returns 'this'. 1057 // Canonicalize only if instantiated, otherwise returns 'this'.
1058 virtual RawAbstractTypeArguments* Canonicalize() const; 1058 virtual RawAbstractTypeArguments* Canonicalize() const;
1059 1059
1060 virtual RawAbstractTypeArguments* InstantiateFrom( 1060 virtual RawAbstractTypeArguments* InstantiateFrom(
1061 const AbstractTypeArguments& instantiator_type_arguments) const; 1061 const AbstractTypeArguments& instantiator_type_arguments,
1062 Error* malformed_error) const;
1062 1063
1063 static const intptr_t kBytesPerElement = kWordSize; 1064 static const intptr_t kBytesPerElement = kWordSize;
1064 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; 1065 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement;
1065 1066
1066 static intptr_t length_offset() { 1067 static intptr_t length_offset() {
1067 return OFFSET_OF(RawTypeArguments, length_); 1068 return OFFSET_OF(RawTypeArguments, length_);
1068 } 1069 }
1069 1070
1070 static intptr_t InstanceSize() { 1071 static intptr_t InstanceSize() {
1071 ASSERT(sizeof(RawTypeArguments) == OFFSET_OF(RawTypeArguments, types_)); 1072 ASSERT(sizeof(RawTypeArguments) == OFFSET_OF(RawTypeArguments, types_));
(...skipping 30 matching lines...) Expand all
1102 // parameter with index i in the first vector can be substituted (or 1103 // parameter with index i in the first vector can be substituted (or
1103 // "instantiated") with the type at index i in the second type argument vector. 1104 // "instantiated") with the type at index i in the second type argument vector.
1104 class InstantiatedTypeArguments : public AbstractTypeArguments { 1105 class InstantiatedTypeArguments : public AbstractTypeArguments {
1105 public: 1106 public:
1106 virtual intptr_t Length() const; 1107 virtual intptr_t Length() const;
1107 virtual RawAbstractType* TypeAt(intptr_t index) const; 1108 virtual RawAbstractType* TypeAt(intptr_t index) const;
1108 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; 1109 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const;
1109 virtual bool IsResolved() const { return true; } 1110 virtual bool IsResolved() const { return true; }
1110 virtual bool IsInstantiated() const { return true; } 1111 virtual bool IsInstantiated() const { return true; }
1111 virtual bool IsUninstantiatedIdentity() const { return false; } 1112 virtual bool IsUninstantiatedIdentity() const { return false; }
1113 virtual bool IsBounded() const { return false; } // Bounds were checked.
1112 1114
1113 RawAbstractTypeArguments* uninstantiated_type_arguments() const { 1115 RawAbstractTypeArguments* uninstantiated_type_arguments() const {
1114 return raw_ptr()->uninstantiated_type_arguments_; 1116 return raw_ptr()->uninstantiated_type_arguments_;
1115 } 1117 }
1116 static intptr_t uninstantiated_type_arguments_offset() { 1118 static intptr_t uninstantiated_type_arguments_offset() {
1117 return OFFSET_OF(RawInstantiatedTypeArguments, 1119 return OFFSET_OF(RawInstantiatedTypeArguments,
1118 uninstantiated_type_arguments_); 1120 uninstantiated_type_arguments_);
1119 } 1121 }
1120 1122
1121 RawAbstractTypeArguments* instantiator_type_arguments() const { 1123 RawAbstractTypeArguments* instantiator_type_arguments() const {
(...skipping 2271 matching lines...) Expand 10 before | Expand all | Expand 10 after
3393 virtual bool HasResolvedTypeClass() const; 3395 virtual bool HasResolvedTypeClass() const;
3394 virtual RawClass* type_class() const; 3396 virtual RawClass* type_class() const;
3395 virtual RawUnresolvedClass* unresolved_class() const; 3397 virtual RawUnresolvedClass* unresolved_class() const;
3396 virtual RawAbstractTypeArguments* arguments() const; 3398 virtual RawAbstractTypeArguments* arguments() const;
3397 virtual intptr_t token_pos() const; 3399 virtual intptr_t token_pos() const;
3398 virtual bool IsInstantiated() const; 3400 virtual bool IsInstantiated() const;
3399 virtual bool Equals(const Instance& other) const; 3401 virtual bool Equals(const Instance& other) const;
3400 3402
3401 // Instantiate this type using the given type argument vector. 3403 // Instantiate this type using the given type argument vector.
3402 // Return a new type, or return 'this' if it is already instantiated. 3404 // Return a new type, or return 'this' if it is already instantiated.
3405 // If malformed_error is not NULL, it may be set to reflect a bound error.
3403 virtual RawAbstractType* InstantiateFrom( 3406 virtual RawAbstractType* InstantiateFrom(
3404 const AbstractTypeArguments& instantiator_type_arguments) const; 3407 const AbstractTypeArguments& instantiator_type_arguments,
3408 Error* malformed_error) const;
3405 3409
3406 // Return the canonical version of this type. 3410 // Return the canonical version of this type.
3407 virtual RawAbstractType* Canonicalize() const; 3411 virtual RawAbstractType* Canonicalize() const;
3408 3412
3409 // The name of this type, including the names of its type arguments, if any. 3413 // The name of this type, including the names of its type arguments, if any.
3410 virtual RawString* Name() const { 3414 virtual RawString* Name() const {
3411 return BuildName(kInternalName); 3415 return BuildName(kInternalName);
3412 } 3416 }
3413 3417
3414 // The name of this type, including the names of its type arguments, if any. 3418 // The name of this type, including the names of its type arguments, if any.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3520 virtual RawClass* type_class() const; 3524 virtual RawClass* type_class() const;
3521 void set_type_class(const Object& value) const; 3525 void set_type_class(const Object& value) const;
3522 virtual RawUnresolvedClass* unresolved_class() const; 3526 virtual RawUnresolvedClass* unresolved_class() const;
3523 RawString* TypeClassName() const; 3527 RawString* TypeClassName() const;
3524 virtual RawAbstractTypeArguments* arguments() const; 3528 virtual RawAbstractTypeArguments* arguments() const;
3525 void set_arguments(const AbstractTypeArguments& value) const; 3529 void set_arguments(const AbstractTypeArguments& value) const;
3526 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } 3530 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; }
3527 virtual bool IsInstantiated() const; 3531 virtual bool IsInstantiated() const;
3528 virtual bool Equals(const Instance& other) const; 3532 virtual bool Equals(const Instance& other) const;
3529 virtual RawAbstractType* InstantiateFrom( 3533 virtual RawAbstractType* InstantiateFrom(
3530 const AbstractTypeArguments& instantiator_type_arguments) const; 3534 const AbstractTypeArguments& instantiator_type_arguments,
3535 Error* malformed_error) const;
3531 virtual RawAbstractType* Canonicalize() const; 3536 virtual RawAbstractType* Canonicalize() const;
3532 3537
3533 virtual intptr_t Hash() const; 3538 virtual intptr_t Hash() const;
3534 3539
3535 static intptr_t InstanceSize() { 3540 static intptr_t InstanceSize() {
3536 return RoundedAllocationSize(sizeof(RawType)); 3541 return RoundedAllocationSize(sizeof(RawType));
3537 } 3542 }
3538 3543
3539 // The type of the literal 'null'. 3544 // The type of the literal 'null'.
3540 static RawType* NullType(); 3545 static RawType* NullType();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3596 3601
3597 // A TypeParameter represents a type parameter of a parameterized class. 3602 // A TypeParameter represents a type parameter of a parameterized class.
3598 // It specifies its index (and its name for debugging purposes), as well as its 3603 // It specifies its index (and its name for debugging purposes), as well as its
3599 // upper bound. 3604 // upper bound.
3600 // For example, the type parameter 'V' is specified as index 1 in the context of 3605 // For example, the type parameter 'V' is specified as index 1 in the context of
3601 // the class HashMap<K, V>. At compile time, the TypeParameter is not 3606 // the class HashMap<K, V>. At compile time, the TypeParameter is not
3602 // instantiated yet, i.e. it is only a place holder. 3607 // instantiated yet, i.e. it is only a place holder.
3603 // Upon finalization, the TypeParameter index is changed to reflect its position 3608 // Upon finalization, the TypeParameter index is changed to reflect its position
3604 // as type argument (rather than type parameter) of the parameterized class. 3609 // as type argument (rather than type parameter) of the parameterized class.
3605 // If the type parameter is declared without an extends clause, its bound is set 3610 // If the type parameter is declared without an extends clause, its bound is set
3606 // to the DynamicType. 3611 // to the ObjectType.
3607 class TypeParameter : public AbstractType { 3612 class TypeParameter : public AbstractType {
3608 public: 3613 public:
3609 virtual bool IsFinalized() const { 3614 virtual bool IsFinalized() const {
3610 ASSERT(raw_ptr()->type_state_ != RawTypeParameter::kFinalizedInstantiated); 3615 ASSERT(raw_ptr()->type_state_ != RawTypeParameter::kFinalizedInstantiated);
3611 return raw_ptr()->type_state_ == RawTypeParameter::kFinalizedUninstantiated; 3616 return raw_ptr()->type_state_ == RawTypeParameter::kFinalizedUninstantiated;
3612 } 3617 }
3613 void set_is_finalized() const; 3618 void set_is_finalized() const;
3614 virtual bool IsBeingFinalized() const { return false; } 3619 virtual bool IsBeingFinalized() const { return false; }
3615 virtual bool IsMalformed() const { return false; } 3620 virtual bool IsMalformed() const { return false; }
3616 virtual bool IsResolved() const { return true; } 3621 virtual bool IsResolved() const { return true; }
3617 virtual bool HasResolvedTypeClass() const { return false; } 3622 virtual bool HasResolvedTypeClass() const { return false; }
3618 RawClass* parameterized_class() const { 3623 RawClass* parameterized_class() const {
3619 return raw_ptr()->parameterized_class_; 3624 return raw_ptr()->parameterized_class_;
3620 } 3625 }
3621 RawString* name() const { return raw_ptr()->name_; } 3626 RawString* name() const { return raw_ptr()->name_; }
3622 intptr_t index() const { return raw_ptr()->index_; } 3627 intptr_t index() const { return raw_ptr()->index_; }
3623 void set_index(intptr_t value) const; 3628 void set_index(intptr_t value) const;
3624 RawAbstractType* bound() const { return raw_ptr()->bound_; } 3629 RawAbstractType* bound() const { return raw_ptr()->bound_; }
3625 void set_bound(const AbstractType& value) const; 3630 void set_bound(const AbstractType& value) const;
3631 void CheckBound(const AbstractType& bounded_type,
3632 const AbstractType& upper_bound,
3633 Error* malformed_error) const;
3626 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } 3634 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; }
3627 virtual bool IsInstantiated() const { return false; } 3635 virtual bool IsInstantiated() const { return false; }
3628 virtual bool Equals(const Instance& other) const; 3636 virtual bool Equals(const Instance& other) const;
3629 virtual RawAbstractType* InstantiateFrom( 3637 virtual RawAbstractType* InstantiateFrom(
3630 const AbstractTypeArguments& instantiator_type_arguments) const; 3638 const AbstractTypeArguments& instantiator_type_arguments,
3639 Error* malformed_error) const;
3631 virtual RawAbstractType* Canonicalize() const { return raw(); } 3640 virtual RawAbstractType* Canonicalize() const { return raw(); }
3632 3641
3633 virtual intptr_t Hash() const; 3642 virtual intptr_t Hash() const;
3634 3643
3635 static intptr_t InstanceSize() { 3644 static intptr_t InstanceSize() {
3636 return RoundedAllocationSize(sizeof(RawTypeParameter)); 3645 return RoundedAllocationSize(sizeof(RawTypeParameter));
3637 } 3646 }
3638 3647
3639 static RawTypeParameter* New(const Class& parameterized_class, 3648 static RawTypeParameter* New(const Class& parameterized_class,
3640 intptr_t index, 3649 intptr_t index,
3641 const String& name, 3650 const String& name,
3642 const AbstractType& bound, 3651 const AbstractType& bound,
3643 intptr_t token_pos); 3652 intptr_t token_pos);
3644 3653
3645 private: 3654 private:
3646 void set_parameterized_class(const Class& value) const; 3655 void set_parameterized_class(const Class& value) const;
3647 void set_name(const String& value) const; 3656 void set_name(const String& value) const;
3648 void set_token_pos(intptr_t token_pos) const; 3657 void set_token_pos(intptr_t token_pos) const;
3649 void set_type_state(int8_t state) const; 3658 void set_type_state(int8_t state) const;
3650 static RawTypeParameter* New(); 3659 static RawTypeParameter* New();
3651 3660
3652 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeParameter, AbstractType); 3661 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeParameter, AbstractType);
3653 friend class Class; 3662 friend class Class;
3654 }; 3663 };
3655 3664
3656 3665
3666 // A BoundedType represents a type instantiated at compile time from a type
3667 // parameter specifying a bound that either cannot be checked at compile time
3668 // because the type or the bound are still uninstantiated or can be checked and
3669 // would trigger a bound error in checked mode. The bound must be checked at
3670 // runtime once the type and its bound are instantiated and when the execution
3671 // mode is known to be checked mode.
3672 class BoundedType : public AbstractType {
3673 public:
3674 virtual bool IsFinalized() const {
3675 return AbstractType::Handle(type()).IsFinalized();
3676 }
3677 virtual bool IsBeingFinalized() const {
3678 return AbstractType::Handle(type()).IsBeingFinalized();
3679 }
3680 virtual bool IsMalformed() const;
3681 virtual RawError* malformed_error() const;
3682 virtual bool IsResolved() const { return true; }
3683 virtual bool HasResolvedTypeClass() const {
3684 return AbstractType::Handle(type()).HasResolvedTypeClass();
3685 }
3686 virtual RawClass* type_class() const {
3687 return AbstractType::Handle(type()).type_class();
3688 }
3689 virtual RawUnresolvedClass* unresolved_class() const {
3690 return AbstractType::Handle(type()).unresolved_class();
3691 }
3692 virtual RawAbstractTypeArguments* arguments() const {
3693 return AbstractType::Handle(type()).arguments();
3694 }
3695 RawAbstractType* type() const { return raw_ptr()->type_; }
3696 RawAbstractType* bound() const { return raw_ptr()->bound_; }
3697 RawTypeParameter* type_parameter() const {
3698 return raw_ptr()->type_parameter_;
3699 }
3700 virtual intptr_t token_pos() const {
3701 return AbstractType::Handle(type()).token_pos();
3702 }
3703 virtual bool IsInstantiated() const {
3704 return AbstractType::Handle(type()).IsInstantiated();
3705 }
3706 virtual bool Equals(const Instance& other) const;
3707 virtual RawAbstractType* InstantiateFrom(
3708 const AbstractTypeArguments& instantiator_type_arguments,
3709 Error* malformed_error) const;
3710 virtual RawAbstractType* Canonicalize() const { return raw(); }
3711
3712 virtual intptr_t Hash() const;
3713
3714 static intptr_t InstanceSize() {
3715 return RoundedAllocationSize(sizeof(RawBoundedType));
3716 }
3717
3718 static RawBoundedType* New(const AbstractType& type,
3719 const AbstractType& bound,
3720 const TypeParameter& type_parameter);
3721
3722 private:
3723 void set_type(const AbstractType& value) const;
3724 void set_bound(const AbstractType& value) const;
3725 void set_type_parameter(const TypeParameter& value) const;
3726
3727 bool is_being_checked() const {
3728 return raw_ptr()->is_being_checked_;
3729 }
3730 void set_is_being_checked(bool value) const;
3731
3732 static RawBoundedType* New();
3733
3734 FINAL_HEAP_OBJECT_IMPLEMENTATION(BoundedType, AbstractType);
3735 friend class Class;
3736 };
3737
3738
3657 class Number : public Instance { 3739 class Number : public Instance {
3658 public: 3740 public:
3659 // TODO(iposva): Fill in a useful Number interface. 3741 // TODO(iposva): Fill in a useful Number interface.
3660 virtual bool IsZero() const { 3742 virtual bool IsZero() const {
3661 // Number is an abstract class. 3743 // Number is an abstract class.
3662 UNREACHABLE(); 3744 UNREACHABLE();
3663 return false; 3745 return false;
3664 } 3746 }
3665 virtual bool IsNegative() const { 3747 virtual bool IsNegative() const {
3666 // Number is an abstract class. 3748 // Number is an abstract class.
(...skipping 2898 matching lines...) Expand 10 before | Expand all | Expand 10 after
6565 6647
6566 6648
6567 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 6649 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6568 intptr_t index) { 6650 intptr_t index) {
6569 return array.At((index * kEntryLength) + kTargetFunctionIndex); 6651 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6570 } 6652 }
6571 6653
6572 } // namespace dart 6654 } // namespace dart
6573 6655
6574 #endif // VM_OBJECT_H_ 6656 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698