| 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 } | 345 } |
| 346 | 346 |
| 347 static const ObjectKind kInstanceKind = kObject; | 347 static const ObjectKind kInstanceKind = kObject; |
| 348 | 348 |
| 349 // Different kinds of type tests. | 349 // Different kinds of type tests. |
| 350 enum TypeTestKind { | 350 enum TypeTestKind { |
| 351 kIsSubtypeOf = 0, | 351 kIsSubtypeOf = 0, |
| 352 kIsMoreSpecificThan | 352 kIsMoreSpecificThan |
| 353 }; | 353 }; |
| 354 | 354 |
| 355 // Different kinds of name visibility. |
| 356 enum NameVisibility { |
| 357 kInternalName = 0, |
| 358 kUserVisibleName |
| 359 }; |
| 360 |
| 355 protected: | 361 protected: |
| 356 // Used for extracting the C++ vtable during bringup. | 362 // Used for extracting the C++ vtable during bringup. |
| 357 Object() : raw_(null_) {} | 363 Object() : raw_(null_) {} |
| 358 | 364 |
| 359 uword raw_value() const { | 365 uword raw_value() const { |
| 360 return reinterpret_cast<uword>(raw()); | 366 return reinterpret_cast<uword>(raw()); |
| 361 } | 367 } |
| 362 | 368 |
| 363 inline void SetRaw(RawObject* value); | 369 inline void SetRaw(RawObject* value); |
| 364 | 370 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 raw_ptr()->instance_kind_ = value; | 487 raw_ptr()->instance_kind_ = value; |
| 482 } | 488 } |
| 483 | 489 |
| 484 intptr_t id() const { return raw_ptr()->id_; } | 490 intptr_t id() const { return raw_ptr()->id_; } |
| 485 void set_id(intptr_t value) const { | 491 void set_id(intptr_t value) const { |
| 486 raw_ptr()->id_ = value; | 492 raw_ptr()->id_ = value; |
| 487 } | 493 } |
| 488 | 494 |
| 489 RawString* Name() const; | 495 RawString* Name() const; |
| 490 | 496 |
| 497 RawString* UserVisibleName() const; |
| 498 |
| 491 RawScript* script() const { return raw_ptr()->script_; } | 499 RawScript* script() const { return raw_ptr()->script_; } |
| 492 | 500 |
| 493 intptr_t token_pos() const { return raw_ptr()->token_pos_; } | 501 intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
| 494 | 502 |
| 495 // This class represents the signature class of a closure function if | 503 // This class represents the signature class of a closure function if |
| 496 // signature_function() is not null. | 504 // signature_function() is not null. |
| 497 // The associated function may be a closure function (with code) or a | 505 // The associated function may be a closure function (with code) or a |
| 498 // signature function (without code) solely describing the result type and | 506 // signature function (without code) solely describing the result type and |
| 499 // parameter types of the signature. | 507 // parameter types of the signature. |
| 500 RawFunction* signature_function() const { | 508 RawFunction* signature_function() const { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 intptr_t token_pos); | 776 intptr_t token_pos); |
| 769 | 777 |
| 770 // Check the subtype or 'more specific' relationship. | 778 // Check the subtype or 'more specific' relationship. |
| 771 bool TypeTest(TypeTestKind test_kind, | 779 bool TypeTest(TypeTestKind test_kind, |
| 772 const AbstractTypeArguments& type_arguments, | 780 const AbstractTypeArguments& type_arguments, |
| 773 const Class& other, | 781 const Class& other, |
| 774 const AbstractTypeArguments& other_type_arguments, | 782 const AbstractTypeArguments& other_type_arguments, |
| 775 Error* malformed_error) const; | 783 Error* malformed_error) const; |
| 776 | 784 |
| 777 HEAP_OBJECT_IMPLEMENTATION(Class, Object); | 785 HEAP_OBJECT_IMPLEMENTATION(Class, Object); |
| 786 friend class AbstractType; |
| 787 friend class Instance; |
| 778 friend class Object; | 788 friend class Object; |
| 779 friend class Instance; | |
| 780 friend class AbstractType; | |
| 781 friend class Type; | 789 friend class Type; |
| 782 }; | 790 }; |
| 783 | 791 |
| 784 | 792 |
| 785 // Unresolved class is used for storing unresolved names which will be resolved | 793 // Unresolved class is used for storing unresolved names which will be resolved |
| 786 // to a class after all classes have been loaded and finalized. | 794 // to a class after all classes have been loaded and finalized. |
| 787 class UnresolvedClass : public Object { | 795 class UnresolvedClass : public Object { |
| 788 public: | 796 public: |
| 789 RawLibraryPrefix* library_prefix() const { | 797 RawLibraryPrefix* library_prefix() const { |
| 790 return raw_ptr()->library_prefix_; | 798 return raw_ptr()->library_prefix_; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 | 848 |
| 841 // Instantiate this type using the given type argument vector. | 849 // Instantiate this type using the given type argument vector. |
| 842 // Return a new type, or return 'this' if it is already instantiated. | 850 // Return a new type, or return 'this' if it is already instantiated. |
| 843 virtual RawAbstractType* InstantiateFrom( | 851 virtual RawAbstractType* InstantiateFrom( |
| 844 const AbstractTypeArguments& instantiator_type_arguments) const; | 852 const AbstractTypeArguments& instantiator_type_arguments) const; |
| 845 | 853 |
| 846 // Return the canonical version of this type. | 854 // Return the canonical version of this type. |
| 847 virtual RawAbstractType* Canonicalize() const; | 855 virtual RawAbstractType* Canonicalize() const; |
| 848 | 856 |
| 849 // The name of this type, including the names of its type arguments, if any. | 857 // The name of this type, including the names of its type arguments, if any. |
| 850 virtual RawString* Name() const; | 858 virtual RawString* Name() const { |
| 859 return BuildName(kInternalName); |
| 860 } |
| 861 |
| 862 // The name of this type, including the names of its type arguments, if any. |
| 863 // Names of internal classes are mapped to their public interfaces. |
| 864 virtual RawString* UserVisibleName() const { |
| 865 return BuildName(kUserVisibleName); |
| 866 } |
| 851 | 867 |
| 852 // The name of this type's class, i.e. without the type argument names of this | 868 // The name of this type's class, i.e. without the type argument names of this |
| 853 // type. | 869 // type. |
| 854 RawString* ClassName() const; | 870 RawString* ClassName() const; |
| 855 | 871 |
| 856 // Check if this type represents the 'Dynamic' type. | 872 // Check if this type represents the 'Dynamic' type. |
| 857 bool IsDynamicType() const { | 873 bool IsDynamicType() const { |
| 858 return HasResolvedTypeClass() && (type_class() == Object::dynamic_class()); | 874 return HasResolvedTypeClass() && (type_class() == Object::dynamic_class()); |
| 859 } | 875 } |
| 860 | 876 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 Error* malformed_error) const { | 929 Error* malformed_error) const { |
| 914 return TypeTest(kIsMoreSpecificThan, other, malformed_error); | 930 return TypeTest(kIsMoreSpecificThan, other, malformed_error); |
| 915 } | 931 } |
| 916 | 932 |
| 917 private: | 933 private: |
| 918 // Check the subtype or 'more specific' relationship. | 934 // Check the subtype or 'more specific' relationship. |
| 919 bool TypeTest(TypeTestKind test_kind, | 935 bool TypeTest(TypeTestKind test_kind, |
| 920 const AbstractType& other, | 936 const AbstractType& other, |
| 921 Error* malformed_error) const; | 937 Error* malformed_error) const; |
| 922 | 938 |
| 939 // Return the internal or public name of this type, including the names of its |
| 940 // type arguments, if any. |
| 941 RawString* BuildName(NameVisibility visibility) const; |
| 942 |
| 923 protected: | 943 protected: |
| 924 HEAP_OBJECT_IMPLEMENTATION(AbstractType, Object); | 944 HEAP_OBJECT_IMPLEMENTATION(AbstractType, Object); |
| 945 friend class AbstractTypeArguments; |
| 925 friend class Class; | 946 friend class Class; |
| 926 friend class AbstractTypeArguments; | 947 friend class Function; |
| 927 }; | 948 }; |
| 928 | 949 |
| 929 | 950 |
| 930 // A Type consists of a class, possibly parameterized with type | 951 // A Type consists of a class, possibly parameterized with type |
| 931 // arguments. Example: C<T1, T2>. | 952 // arguments. Example: C<T1, T2>. |
| 932 // An unresolved class is a String specifying the class name. | 953 // An unresolved class is a String specifying the class name. |
| 933 // | 954 // |
| 934 // Caution: 'RawType*' denotes a 'raw' pointer to a VM object of class Type, as | 955 // Caution: 'RawType*' denotes a 'raw' pointer to a VM object of class Type, as |
| 935 // opposed to 'Type' denoting a 'handle' to the same object. 'RawType' does not | 956 // opposed to 'Type' denoting a 'handle' to the same object. 'RawType' does not |
| 936 // relate to a 'raw type', as opposed to a 'cooked type' or 'rare type'. | 957 // relate to a 'raw type', as opposed to a 'cooked type' or 'rare type'. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 return raw_ptr()->type_state_ == RawTypeParameter::kFinalizedUninstantiated; | 1064 return raw_ptr()->type_state_ == RawTypeParameter::kFinalizedUninstantiated; |
| 1044 } | 1065 } |
| 1045 void set_is_finalized() const; | 1066 void set_is_finalized() const; |
| 1046 virtual bool IsBeingFinalized() const { return false; } | 1067 virtual bool IsBeingFinalized() const { return false; } |
| 1047 virtual bool IsMalformed() const { return false; } | 1068 virtual bool IsMalformed() const { return false; } |
| 1048 virtual bool IsResolved() const { return true; } | 1069 virtual bool IsResolved() const { return true; } |
| 1049 virtual bool HasResolvedTypeClass() const { return false; } | 1070 virtual bool HasResolvedTypeClass() const { return false; } |
| 1050 RawClass* parameterized_class() const { | 1071 RawClass* parameterized_class() const { |
| 1051 return raw_ptr()->parameterized_class_; | 1072 return raw_ptr()->parameterized_class_; |
| 1052 } | 1073 } |
| 1053 virtual RawString* Name() const { return raw_ptr()->name_; } | 1074 RawString* name() const { return raw_ptr()->name_; } |
| 1054 intptr_t index() const { return raw_ptr()->index_; } | 1075 intptr_t index() const { return raw_ptr()->index_; } |
| 1055 void set_index(intptr_t value) const; | 1076 void set_index(intptr_t value) const; |
| 1056 RawAbstractType* bound() const { return raw_ptr()->bound_; } | 1077 RawAbstractType* bound() const { return raw_ptr()->bound_; } |
| 1057 void set_bound(const AbstractType& value) const; | 1078 void set_bound(const AbstractType& value) const; |
| 1058 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } | 1079 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
| 1059 virtual bool IsInstantiated() const { return false; } | 1080 virtual bool IsInstantiated() const { return false; } |
| 1060 virtual bool Equals(const AbstractType& other) const; | 1081 virtual bool Equals(const AbstractType& other) const; |
| 1061 virtual bool IsIdentical(const AbstractType& other, | 1082 virtual bool IsIdentical(const AbstractType& other, |
| 1062 bool check_type_parameter_bound) const; | 1083 bool check_type_parameter_bound) const; |
| 1063 virtual RawAbstractType* InstantiateFrom( | 1084 virtual RawAbstractType* InstantiateFrom( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 // Return 'this' if this type argument vector is instantiated, i.e. if it does | 1125 // Return 'this' if this type argument vector is instantiated, i.e. if it does |
| 1105 // not refer to type parameters. Otherwise, return a new type argument vector | 1126 // not refer to type parameters. Otherwise, return a new type argument vector |
| 1106 // where each reference to a type parameter is replaced with the corresponding | 1127 // where each reference to a type parameter is replaced with the corresponding |
| 1107 // type of the instantiator type argument vector. | 1128 // type of the instantiator type argument vector. |
| 1108 virtual RawAbstractTypeArguments* InstantiateFrom( | 1129 virtual RawAbstractTypeArguments* InstantiateFrom( |
| 1109 const AbstractTypeArguments& instantiator_type_arguments) const; | 1130 const AbstractTypeArguments& instantiator_type_arguments) const; |
| 1110 | 1131 |
| 1111 // Do not canonicalize InstantiatedTypeArguments or NULL objects | 1132 // Do not canonicalize InstantiatedTypeArguments or NULL objects |
| 1112 virtual RawAbstractTypeArguments* Canonicalize() const { return this->raw(); } | 1133 virtual RawAbstractTypeArguments* Canonicalize() const { return this->raw(); } |
| 1113 | 1134 |
| 1114 // The name of this type argument vector, e.g. "<T, Dynamic, List<T>, int>". | 1135 // The name of this type argument vector, e.g. "<T, Dynamic, List<T>, Smi>". |
| 1115 virtual RawString* Name() const { | 1136 virtual RawString* Name() const { |
| 1116 return SubvectorName(0, Length()); | 1137 return SubvectorName(0, Length(), kInternalName); |
| 1117 } | 1138 } |
| 1118 | 1139 |
| 1119 // The name of a subvector of this type argument vector, e.g. "<T, Dynamic>". | 1140 // The name of this type argument vector, e.g. "<T, Dynamic, List<T>, int>". |
| 1120 virtual RawString* SubvectorName(intptr_t from_index, intptr_t len) const; | 1141 // Names of internal classes are mapped to their public interfaces. |
| 1142 virtual RawString* UserVisibleName() const { |
| 1143 return SubvectorName(0, Length(), kUserVisibleName); |
| 1144 } |
| 1121 | 1145 |
| 1122 // Check if this type argument vector consists solely of DynamicType, | 1146 // Check if this type argument vector consists solely of DynamicType, |
| 1123 // considering only a prefix of length 'len'. | 1147 // considering only a prefix of length 'len'. |
| 1124 bool IsRaw(intptr_t len) const { | 1148 bool IsRaw(intptr_t len) const { |
| 1125 return IsDynamicTypes(false, len); | 1149 return IsDynamicTypes(false, len); |
| 1126 } | 1150 } |
| 1127 | 1151 |
| 1128 // Check if this type argument vector would consist solely of DynamicType if | 1152 // Check if this type argument vector would consist solely of DynamicType if |
| 1129 // it was instantiated from a raw (null) instantiator, i.e. consider each type | 1153 // it was instantiated from a raw (null) instantiator, i.e. consider each type |
| 1130 // parameter as it would be first instantiated from a vector of dynamic types. | 1154 // parameter as it would be first instantiated from a vector of dynamic types. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 // instantiated from a vector of dynamic types. | 1195 // instantiated from a vector of dynamic types. |
| 1172 bool IsDynamicTypes(bool raw_instantiated, intptr_t len) const; | 1196 bool IsDynamicTypes(bool raw_instantiated, intptr_t len) const; |
| 1173 | 1197 |
| 1174 // Check the subtype or 'more specific' relationship, considering only a | 1198 // Check the subtype or 'more specific' relationship, considering only a |
| 1175 // prefix of length 'len'. | 1199 // prefix of length 'len'. |
| 1176 bool TypeTest(TypeTestKind test_kind, | 1200 bool TypeTest(TypeTestKind test_kind, |
| 1177 const AbstractTypeArguments& other, | 1201 const AbstractTypeArguments& other, |
| 1178 intptr_t len, | 1202 intptr_t len, |
| 1179 Error* malformed_error) const; | 1203 Error* malformed_error) const; |
| 1180 | 1204 |
| 1205 // Return the internal or public name of a subvector of this type argument |
| 1206 // vector, e.g. "<T, Dynamic, List<T>, int>". |
| 1207 RawString* SubvectorName(intptr_t from_index, |
| 1208 intptr_t len, |
| 1209 NameVisibility name_visibility) const; |
| 1210 |
| 1181 protected: | 1211 protected: |
| 1182 HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments, Object); | 1212 HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments, Object); |
| 1213 friend class AbstractType; |
| 1183 friend class Class; | 1214 friend class Class; |
| 1184 }; | 1215 }; |
| 1185 | 1216 |
| 1186 | 1217 |
| 1187 // A TypeArguments is an array of AbstractType. | 1218 // A TypeArguments is an array of AbstractType. |
| 1188 class TypeArguments : public AbstractTypeArguments { | 1219 class TypeArguments : public AbstractTypeArguments { |
| 1189 public: | 1220 public: |
| 1190 virtual intptr_t Length() const; | 1221 virtual intptr_t Length() const; |
| 1191 virtual RawAbstractType* TypeAt(intptr_t index) const; | 1222 virtual RawAbstractType* TypeAt(intptr_t index) const; |
| 1192 static intptr_t type_at_offset(intptr_t index) { | 1223 static intptr_t type_at_offset(intptr_t index) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1283 HEAP_OBJECT_IMPLEMENTATION(InstantiatedTypeArguments, AbstractTypeArguments); | 1314 HEAP_OBJECT_IMPLEMENTATION(InstantiatedTypeArguments, AbstractTypeArguments); |
| 1284 friend class Class; | 1315 friend class Class; |
| 1285 }; | 1316 }; |
| 1286 | 1317 |
| 1287 | 1318 |
| 1288 class Function : public Object { | 1319 class Function : public Object { |
| 1289 public: | 1320 public: |
| 1290 RawString* name() const { return raw_ptr()->name_; } | 1321 RawString* name() const { return raw_ptr()->name_; } |
| 1291 | 1322 |
| 1292 // Build a string of the form '<T, R>(T, [b: B, c: C]) => R' representing the | 1323 // Build a string of the form '<T, R>(T, [b: B, c: C]) => R' representing the |
| 1293 // signature of the given function. | 1324 // internal signature of the given function. |
| 1294 RawString* Signature() const { | 1325 RawString* Signature() const { |
| 1295 return BuildSignature(false, TypeArguments::Handle()); | 1326 const bool instantiate = false; |
| 1327 return BuildSignature(instantiate, kInternalName, TypeArguments::Handle()); |
| 1296 } | 1328 } |
| 1297 | 1329 |
| 1298 // Build a string of the form '(A, [b: B, c: C]) => D' representing the | 1330 // Build a string of the form '(A, [b: B, c: C]) => D' representing the |
| 1299 // signature of the given function, where all generic types (e.g. '<T, R>' in | 1331 // signature of the given function, where all generic types (e.g. '<T, R>' in |
| 1300 // '<T, R>(T, [b: B, c: C]) => R') are instantiated using the given | 1332 // '<T, R>(T, [b: B, c: C]) => R') are instantiated using the given |
| 1301 // instantiator type argument vector (e.g. '<A, D>'). | 1333 // instantiator type argument vector (e.g. '<A, D>'). |
| 1302 RawString* InstantiatedSignatureFrom( | 1334 RawString* InstantiatedSignatureFrom( |
| 1303 const AbstractTypeArguments& instantiator) const { | 1335 const AbstractTypeArguments& instantiator, |
| 1304 return BuildSignature(true, instantiator); | 1336 NameVisibility name_visibility) const { |
| 1337 const bool instantiate = true; |
| 1338 return BuildSignature(instantiate, name_visibility, instantiator); |
| 1305 } | 1339 } |
| 1306 | 1340 |
| 1307 // Returns true if the signature of this function is instantiated, i.e. if it | 1341 // Returns true if the signature of this function is instantiated, i.e. if it |
| 1308 // does not involve generic parameter types or generic result type. | 1342 // does not involve generic parameter types or generic result type. |
| 1309 bool HasInstantiatedSignature() const; | 1343 bool HasInstantiatedSignature() const; |
| 1310 | 1344 |
| 1311 RawClass* owner() const { return raw_ptr()->owner_; } | 1345 RawClass* owner() const { return raw_ptr()->owner_; } |
| 1312 void set_owner(const Class& value) const; | 1346 void set_owner(const Class& value) const; |
| 1313 | 1347 |
| 1314 RawAbstractType* result_type() const { return raw_ptr()->result_type_; } | 1348 RawAbstractType* result_type() const { return raw_ptr()->result_type_; } |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1575 void set_name(const String& value) const; | 1609 void set_name(const String& value) const; |
| 1576 void set_kind(RawFunction::Kind value) const; | 1610 void set_kind(RawFunction::Kind value) const; |
| 1577 void set_is_static(bool is_static) const; | 1611 void set_is_static(bool is_static) const; |
| 1578 void set_is_const(bool is_const) const; | 1612 void set_is_const(bool is_const) const; |
| 1579 void set_parent_function(const Function& value) const; | 1613 void set_parent_function(const Function& value) const; |
| 1580 void set_token_pos(intptr_t value) const; | 1614 void set_token_pos(intptr_t value) const; |
| 1581 void set_implicit_closure_function(const Function& value) const; | 1615 void set_implicit_closure_function(const Function& value) const; |
| 1582 static RawFunction* New(); | 1616 static RawFunction* New(); |
| 1583 | 1617 |
| 1584 RawString* BuildSignature(bool instantiate, | 1618 RawString* BuildSignature(bool instantiate, |
| 1619 NameVisibility name_visibility, |
| 1585 const AbstractTypeArguments& instantiator) const; | 1620 const AbstractTypeArguments& instantiator) const; |
| 1586 | 1621 |
| 1587 // Check the subtype or 'more specific' relationship. | 1622 // Check the subtype or 'more specific' relationship. |
| 1588 bool TypeTest(TypeTestKind test_kind, | 1623 bool TypeTest(TypeTestKind test_kind, |
| 1589 const AbstractTypeArguments& type_arguments, | 1624 const AbstractTypeArguments& type_arguments, |
| 1590 const Function& other, | 1625 const Function& other, |
| 1591 const AbstractTypeArguments& other_type_arguments, | 1626 const AbstractTypeArguments& other_type_arguments, |
| 1592 Error* malformed_error) const; | 1627 Error* malformed_error) const; |
| 1593 | 1628 |
| 1594 // Checks the type of the formal parameter at the given position for | 1629 // Checks the type of the formal parameter at the given position for |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1994 static RawLibrary* NewLibraryHelper(const String& url, | 2029 static RawLibrary* NewLibraryHelper(const String& url, |
| 1995 bool import_core_lib); | 2030 bool import_core_lib); |
| 1996 void AddImportedInto(const Library& library) const; | 2031 void AddImportedInto(const Library& library) const; |
| 1997 RawObject* LookupObjectFiltered(const String& name, | 2032 RawObject* LookupObjectFiltered(const String& name, |
| 1998 const Library& filter_lib) const; | 2033 const Library& filter_lib) const; |
| 1999 RawLibrary* LookupObjectInImporter(const String& name) const; | 2034 RawLibrary* LookupObjectInImporter(const String& name) const; |
| 2000 RawString* FindDuplicateDefinition() const; | 2035 RawString* FindDuplicateDefinition() const; |
| 2001 | 2036 |
| 2002 HEAP_OBJECT_IMPLEMENTATION(Library, Object); | 2037 HEAP_OBJECT_IMPLEMENTATION(Library, Object); |
| 2003 friend class Class; | 2038 friend class Class; |
| 2039 friend class Debugger; |
| 2004 friend class DictionaryIterator; | 2040 friend class DictionaryIterator; |
| 2005 friend class Debugger; | |
| 2006 friend class Isolate; | 2041 friend class Isolate; |
| 2007 }; | 2042 }; |
| 2008 | 2043 |
| 2009 | 2044 |
| 2010 class LibraryPrefix : public Object { | 2045 class LibraryPrefix : public Object { |
| 2011 public: | 2046 public: |
| 2012 RawString* name() const { return raw_ptr()->name_; } | 2047 RawString* name() const { return raw_ptr()->name_; } |
| 2013 RawArray* libraries() const { return raw_ptr()->libraries_; } | 2048 RawArray* libraries() const { return raw_ptr()->libraries_; } |
| 2014 intptr_t num_libs() const { return raw_ptr()->num_libs_; } | 2049 intptr_t num_libs() const { return raw_ptr()->num_libs_; } |
| 2015 | 2050 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2080 raw_ptr()->code_ = code; | 2115 raw_ptr()->code_ = code; |
| 2081 } | 2116 } |
| 2082 | 2117 |
| 2083 // New is a private method as RawInstruction and RawCode objects should | 2118 // New is a private method as RawInstruction and RawCode objects should |
| 2084 // only be created using the Code::FinalizeCode method. This method creates | 2119 // only be created using the Code::FinalizeCode method. This method creates |
| 2085 // the RawInstruction and RawCode objects, sets up the pointer offsets | 2120 // the RawInstruction and RawCode objects, sets up the pointer offsets |
| 2086 // and links the two in a GC safe manner. | 2121 // and links the two in a GC safe manner. |
| 2087 static RawInstructions* New(intptr_t size); | 2122 static RawInstructions* New(intptr_t size); |
| 2088 | 2123 |
| 2089 HEAP_OBJECT_IMPLEMENTATION(Instructions, Object); | 2124 HEAP_OBJECT_IMPLEMENTATION(Instructions, Object); |
| 2125 friend class Class; |
| 2090 friend class Code; | 2126 friend class Code; |
| 2091 friend class Class; | |
| 2092 }; | 2127 }; |
| 2093 | 2128 |
| 2094 | 2129 |
| 2095 class LocalVarDescriptors : public Object { | 2130 class LocalVarDescriptors : public Object { |
| 2096 public: | 2131 public: |
| 2097 intptr_t Length() const; | 2132 intptr_t Length() const; |
| 2098 | 2133 |
| 2099 RawString* GetName(intptr_t var_index) const; | 2134 RawString* GetName(intptr_t var_index) const; |
| 2100 | 2135 |
| 2101 void SetVar(intptr_t var_index, | 2136 void SetVar(intptr_t var_index, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2248 } | 2283 } |
| 2249 | 2284 |
| 2250 bool InRange(intptr_t offset) const { return offset < SizeInBits(); } | 2285 bool InRange(intptr_t offset) const { return offset < SizeInBits(); } |
| 2251 | 2286 |
| 2252 bool GetBit(intptr_t bit_offset) const; | 2287 bool GetBit(intptr_t bit_offset) const; |
| 2253 void SetBit(intptr_t bit_offset, bool value) const; | 2288 void SetBit(intptr_t bit_offset, bool value) const; |
| 2254 | 2289 |
| 2255 void set_bitmap_size_in_bytes(intptr_t value) const; | 2290 void set_bitmap_size_in_bytes(intptr_t value) const; |
| 2256 | 2291 |
| 2257 HEAP_OBJECT_IMPLEMENTATION(Stackmap, Object); | 2292 HEAP_OBJECT_IMPLEMENTATION(Stackmap, Object); |
| 2293 friend class BitmapBuilder; |
| 2258 friend class Class; | 2294 friend class Class; |
| 2259 friend class BitmapBuilder; | |
| 2260 }; | 2295 }; |
| 2261 | 2296 |
| 2262 | 2297 |
| 2263 class ExceptionHandlers : public Object { | 2298 class ExceptionHandlers : public Object { |
| 2264 public: | 2299 public: |
| 2265 intptr_t Length() const; | 2300 intptr_t Length() const; |
| 2266 | 2301 |
| 2267 intptr_t TryIndex(intptr_t index) const; | 2302 intptr_t TryIndex(intptr_t index) const; |
| 2268 intptr_t HandlerPC(intptr_t index) const; | 2303 intptr_t HandlerPC(intptr_t index) const; |
| 2269 | 2304 |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2938 static RawInteger* New(const String& str, Heap::Space space = Heap::kNew); | 2973 static RawInteger* New(const String& str, Heap::Space space = Heap::kNew); |
| 2939 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew); | 2974 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew); |
| 2940 | 2975 |
| 2941 virtual double AsDoubleValue() const; | 2976 virtual double AsDoubleValue() const; |
| 2942 virtual int64_t AsInt64Value() const; | 2977 virtual int64_t AsInt64Value() const; |
| 2943 | 2978 |
| 2944 // Returns 0, -1 or 1. | 2979 // Returns 0, -1 or 1. |
| 2945 virtual int CompareWith(const Integer& other) const; | 2980 virtual int CompareWith(const Integer& other) const; |
| 2946 | 2981 |
| 2947 OBJECT_IMPLEMENTATION(Integer, Number); | 2982 OBJECT_IMPLEMENTATION(Integer, Number); |
| 2983 friend class Class; |
| 2948 }; | 2984 }; |
| 2949 | 2985 |
| 2950 | 2986 |
| 2951 class Smi : public Integer { | 2987 class Smi : public Integer { |
| 2952 public: | 2988 public: |
| 2953 // Smi value range is from -(2^N) to (2^N)-1. | 2989 // Smi value range is from -(2^N) to (2^N)-1. |
| 2954 // N=30 (32-bit build) or N=62 (64-bit build). | 2990 // N=30 (32-bit build) or N=62 (64-bit build). |
| 2955 static const intptr_t kBits = kBitsPerWord - 2; | 2991 static const intptr_t kBits = kBitsPerWord - 2; |
| 2956 static const intptr_t kMaxValue = (static_cast<intptr_t>(1) << kBits) - 1; | 2992 static const intptr_t kMaxValue = (static_cast<intptr_t>(1) << kBits) - 1; |
| 2957 static const intptr_t kMinValue = -(static_cast<intptr_t>(1) << kBits); | 2993 static const intptr_t kMinValue = -(static_cast<intptr_t>(1) << kBits); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2993 | 3029 |
| 2994 static bool IsValid(intptr_t value) { | 3030 static bool IsValid(intptr_t value) { |
| 2995 return (value >= kMinValue) && (value <= kMaxValue); | 3031 return (value >= kMinValue) && (value <= kMaxValue); |
| 2996 } | 3032 } |
| 2997 | 3033 |
| 2998 static bool IsValid64(int64_t value) { | 3034 static bool IsValid64(int64_t value) { |
| 2999 return (value >= kMinValue) && (value <= kMaxValue); | 3035 return (value >= kMinValue) && (value <= kMaxValue); |
| 3000 } | 3036 } |
| 3001 | 3037 |
| 3002 private: | 3038 private: |
| 3003 friend class Api; // For ValueFromRaw | |
| 3004 | |
| 3005 static intptr_t ValueFromRaw(uword raw_value) { | 3039 static intptr_t ValueFromRaw(uword raw_value) { |
| 3006 intptr_t value = raw_value; | 3040 intptr_t value = raw_value; |
| 3007 ASSERT((value & kSmiTagMask) == kSmiTag); | 3041 ASSERT((value & kSmiTagMask) == kSmiTag); |
| 3008 return (value >> kSmiTagShift); | 3042 return (value >> kSmiTagShift); |
| 3009 } | 3043 } |
| 3010 static cpp_vtable handle_vtable_; | 3044 static cpp_vtable handle_vtable_; |
| 3011 | 3045 |
| 3012 OBJECT_IMPLEMENTATION(Smi, Integer); | 3046 OBJECT_IMPLEMENTATION(Smi, Integer); |
| 3047 friend class Api; // For ValueFromRaw |
| 3048 friend class Class; |
| 3013 friend class Object; | 3049 friend class Object; |
| 3014 friend class Class; | |
| 3015 }; | 3050 }; |
| 3016 | 3051 |
| 3017 | 3052 |
| 3018 class Mint : public Integer { | 3053 class Mint : public Integer { |
| 3019 public: | 3054 public: |
| 3020 static const intptr_t kBits = 63; // 64-th bit is sign. | 3055 static const intptr_t kBits = 63; // 64-th bit is sign. |
| 3021 static const int64_t kMaxValue = | 3056 static const int64_t kMaxValue = |
| 3022 static_cast<int64_t>(DART_2PART_UINT64_C(0x7FFFFFFF, FFFFFFFF)); | 3057 static_cast<int64_t>(DART_2PART_UINT64_C(0x7FFFFFFF, FFFFFFFF)); |
| 3023 static const int64_t kMinValue = | 3058 static const int64_t kMinValue = |
| 3024 static_cast<int64_t>(DART_2PART_UINT64_C(0x80000000, 00000000)); | 3059 static_cast<int64_t>(DART_2PART_UINT64_C(0x80000000, 00000000)); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3118 Chunk* ChunkAddr(intptr_t index) const { | 3153 Chunk* ChunkAddr(intptr_t index) const { |
| 3119 ASSERT(0 <= index); | 3154 ASSERT(0 <= index); |
| 3120 ASSERT(index < Length()); | 3155 ASSERT(index < Length()); |
| 3121 uword digits_start = reinterpret_cast<uword>(raw_ptr()) + sizeof(RawBigint); | 3156 uword digits_start = reinterpret_cast<uword>(raw_ptr()) + sizeof(RawBigint); |
| 3122 return &(reinterpret_cast<Chunk*>(digits_start)[index]); | 3157 return &(reinterpret_cast<Chunk*>(digits_start)[index]); |
| 3123 } | 3158 } |
| 3124 | 3159 |
| 3125 static RawBigint* Allocate(intptr_t length, Heap::Space space = Heap::kNew); | 3160 static RawBigint* Allocate(intptr_t length, Heap::Space space = Heap::kNew); |
| 3126 | 3161 |
| 3127 HEAP_OBJECT_IMPLEMENTATION(Bigint, Integer); | 3162 HEAP_OBJECT_IMPLEMENTATION(Bigint, Integer); |
| 3163 friend class BigintOperations; |
| 3128 friend class Class; | 3164 friend class Class; |
| 3129 friend class BigintOperations; | |
| 3130 }; | 3165 }; |
| 3131 | 3166 |
| 3132 | 3167 |
| 3133 class Double : public Number { | 3168 class Double : public Number { |
| 3134 public: | 3169 public: |
| 3135 double value() const { | 3170 double value() const { |
| 3136 return raw_ptr()->value_; | 3171 return raw_ptr()->value_; |
| 3137 } | 3172 } |
| 3138 | 3173 |
| 3139 bool EqualsToDouble(double value) const; | 3174 bool EqualsToDouble(double value) const; |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3649 return value ? Bool::True() : Bool::False(); | 3684 return value ? Bool::True() : Bool::False(); |
| 3650 } | 3685 } |
| 3651 | 3686 |
| 3652 private: | 3687 private: |
| 3653 void set_value(bool value) const { raw_ptr()->value_ = value; } | 3688 void set_value(bool value) const { raw_ptr()->value_ = value; } |
| 3654 | 3689 |
| 3655 // New should only be called to initialize the two legal bool values. | 3690 // New should only be called to initialize the two legal bool values. |
| 3656 static RawBool* New(bool value); | 3691 static RawBool* New(bool value); |
| 3657 | 3692 |
| 3658 HEAP_OBJECT_IMPLEMENTATION(Bool, Instance); | 3693 HEAP_OBJECT_IMPLEMENTATION(Bool, Instance); |
| 3694 friend class Class; |
| 3659 friend class Object; // To initialize the true and false values. | 3695 friend class Object; // To initialize the true and false values. |
| 3660 friend class Class; | |
| 3661 }; | 3696 }; |
| 3662 | 3697 |
| 3663 | 3698 |
| 3664 class Array : public Instance { | 3699 class Array : public Instance { |
| 3665 public: | 3700 public: |
| 3666 intptr_t Length() const { | 3701 intptr_t Length() const { |
| 3667 ASSERT(!IsNull()); | 3702 ASSERT(!IsNull()); |
| 3668 return Smi::Value(raw_ptr()->length_); | 3703 return Smi::Value(raw_ptr()->length_); |
| 3669 } | 3704 } |
| 3670 static intptr_t length_offset() { return OFFSET_OF(RawArray, length_); } | 3705 static intptr_t length_offset() { return OFFSET_OF(RawArray, length_); } |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3843 private: | 3878 private: |
| 3844 RawArray* DataArray() const { return data()->ptr(); } | 3879 RawArray* DataArray() const { return data()->ptr(); } |
| 3845 RawObject** ObjectAddr(intptr_t index) const { | 3880 RawObject** ObjectAddr(intptr_t index) const { |
| 3846 ASSERT((index >= 0) && (index < Length())); | 3881 ASSERT((index >= 0) && (index < Length())); |
| 3847 return &(DataArray()->data()[index]); | 3882 return &(DataArray()->data()[index]); |
| 3848 } | 3883 } |
| 3849 | 3884 |
| 3850 static const int kDefaultInitialCapacity = 4; | 3885 static const int kDefaultInitialCapacity = 4; |
| 3851 | 3886 |
| 3852 HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance); | 3887 HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance); |
| 3888 friend class Array; |
| 3853 friend class Class; | 3889 friend class Class; |
| 3854 friend class Array; | |
| 3855 }; | 3890 }; |
| 3856 | 3891 |
| 3857 | 3892 |
| 3858 class ByteArray : public Instance { | 3893 class ByteArray : public Instance { |
| 3859 public: | 3894 public: |
| 3860 intptr_t Length() const { | 3895 intptr_t Length() const { |
| 3861 ASSERT(!IsNull()); | 3896 ASSERT(!IsNull()); |
| 3862 return Smi::Value(raw_ptr()->length_); | 3897 return Smi::Value(raw_ptr()->length_); |
| 3863 } | 3898 } |
| 3864 | 3899 |
| (...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5168 if (this->CharAt(i) != str.CharAt(begin_index + i)) { | 5203 if (this->CharAt(i) != str.CharAt(begin_index + i)) { |
| 5169 return false; | 5204 return false; |
| 5170 } | 5205 } |
| 5171 } | 5206 } |
| 5172 return true; | 5207 return true; |
| 5173 } | 5208 } |
| 5174 | 5209 |
| 5175 } // namespace dart | 5210 } // namespace dart |
| 5176 | 5211 |
| 5177 #endif // VM_OBJECT_H_ | 5212 #endif // VM_OBJECT_H_ |
| OLD | NEW |