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 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 // Returns true if all types of this vector are finalized. | 1206 // Returns true if all types of this vector are finalized. |
1207 virtual bool IsFinalized() const { return true; } | 1207 virtual bool IsFinalized() const { return true; } |
1208 | 1208 |
1209 // Return 'this' if this type argument vector is instantiated, i.e. if it does | 1209 // Return 'this' if this type argument vector is instantiated, i.e. if it does |
1210 // not refer to type parameters. Otherwise, return a new type argument vector | 1210 // not refer to type parameters. Otherwise, return a new type argument vector |
1211 // where each reference to a type parameter is replaced with the corresponding | 1211 // where each reference to a type parameter is replaced with the corresponding |
1212 // type of the instantiator type argument vector. | 1212 // type of the instantiator type argument vector. |
1213 // If bound_error is not NULL, it may be set to reflect a bound error. | 1213 // If bound_error is not NULL, it may be set to reflect a bound error. |
1214 virtual RawAbstractTypeArguments* InstantiateFrom( | 1214 virtual RawAbstractTypeArguments* InstantiateFrom( |
1215 const AbstractTypeArguments& instantiator_type_arguments, | 1215 const AbstractTypeArguments& instantiator_type_arguments, |
1216 Error* bound_error) const; | 1216 Error* bound_error, |
| 1217 GrowableObjectArray* trail = NULL) const; |
1217 | 1218 |
1218 // Do not clone InstantiatedTypeArguments or null vectors, since they are | 1219 // Do not clone InstantiatedTypeArguments or null vectors, since they are |
1219 // considered finalized. | 1220 // considered finalized. |
1220 virtual RawAbstractTypeArguments* CloneUnfinalized() const { | 1221 virtual RawAbstractTypeArguments* CloneUnfinalized() const { |
1221 return this->raw(); | 1222 return this->raw(); |
1222 } | 1223 } |
1223 | 1224 |
1224 // Null vectors are canonical. | 1225 // Null vectors are canonical. |
1225 virtual RawAbstractTypeArguments* Canonicalize() const { return this->raw(); } | 1226 virtual RawAbstractTypeArguments* Canonicalize( |
| 1227 GrowableObjectArray* trail = NULL) const { |
| 1228 return this->raw(); |
| 1229 } |
1226 | 1230 |
1227 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, Smi>". | 1231 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, Smi>". |
1228 virtual RawString* Name() const { | 1232 virtual RawString* Name() const { |
1229 return SubvectorName(0, Length(), kInternalName); | 1233 return SubvectorName(0, Length(), kInternalName); |
1230 } | 1234 } |
1231 | 1235 |
1232 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, int>". | 1236 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, int>". |
1233 // Names of internal classes are mapped to their public interfaces. | 1237 // Names of internal classes are mapped to their public interfaces. |
1234 virtual RawString* UserVisibleName() const { | 1238 virtual RawString* UserVisibleName() const { |
1235 return SubvectorName(0, Length(), kUserVisibleName); | 1239 return SubvectorName(0, Length(), kUserVisibleName); |
(...skipping 25 matching lines...) Expand all Loading... |
1261 // Check the 'more specific' relationship, considering only a subvector of | 1265 // Check the 'more specific' relationship, considering only a subvector of |
1262 // length 'len' starting at 'from_index'. | 1266 // length 'len' starting at 'from_index'. |
1263 bool IsMoreSpecificThan(const AbstractTypeArguments& other, | 1267 bool IsMoreSpecificThan(const AbstractTypeArguments& other, |
1264 intptr_t from_index, | 1268 intptr_t from_index, |
1265 intptr_t len, | 1269 intptr_t len, |
1266 Error* bound_error) const { | 1270 Error* bound_error) const { |
1267 return TypeTest(kIsMoreSpecificThan, other, from_index, len, bound_error); | 1271 return TypeTest(kIsMoreSpecificThan, other, from_index, len, bound_error); |
1268 } | 1272 } |
1269 | 1273 |
1270 // Check if the vectors are equal. | 1274 // Check if the vectors are equal. |
1271 bool Equals(const AbstractTypeArguments& other) const; | 1275 bool Equals(const AbstractTypeArguments& other) const { |
| 1276 return IsEquivalent(other); |
| 1277 } |
| 1278 |
| 1279 bool IsEquivalent(const AbstractTypeArguments& other, |
| 1280 GrowableObjectArray* trail = NULL) const; |
1272 | 1281 |
1273 // UNREACHABLEs as AbstractTypeArguments is an abstract class. | 1282 // UNREACHABLEs as AbstractTypeArguments is an abstract class. |
1274 virtual intptr_t Length() const; | 1283 virtual intptr_t Length() const; |
1275 virtual RawAbstractType* TypeAt(intptr_t index) const; | 1284 virtual RawAbstractType* TypeAt(intptr_t index) const; |
1276 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; | 1285 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; |
1277 virtual bool IsResolved() const; | 1286 virtual bool IsResolved() const; |
1278 virtual bool IsInstantiated() const; | 1287 virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const; |
1279 virtual bool IsUninstantiatedIdentity() const; | 1288 virtual bool IsUninstantiatedIdentity() const; |
1280 virtual bool CanShareInstantiatorTypeArguments( | 1289 virtual bool CanShareInstantiatorTypeArguments( |
1281 const Class& instantiator_class) const; | 1290 const Class& instantiator_class) const; |
1282 virtual bool IsBounded() const; | 1291 virtual bool IsBounded() const; |
1283 | 1292 |
1284 virtual intptr_t Hash() const; | 1293 virtual intptr_t Hash() const; |
1285 | 1294 |
1286 private: | 1295 private: |
1287 // Check if the subvector of length 'len' starting at 'from_index' of this | 1296 // Check if the subvector of length 'len' starting at 'from_index' of this |
1288 // type argument vector consists solely of DynamicType. | 1297 // type argument vector consists solely of DynamicType. |
(...skipping 27 matching lines...) Expand all Loading... |
1316 // A TypeArguments is an array of AbstractType. | 1325 // A TypeArguments is an array of AbstractType. |
1317 class TypeArguments : public AbstractTypeArguments { | 1326 class TypeArguments : public AbstractTypeArguments { |
1318 public: | 1327 public: |
1319 virtual intptr_t Length() const; | 1328 virtual intptr_t Length() const; |
1320 virtual RawAbstractType* TypeAt(intptr_t index) const; | 1329 virtual RawAbstractType* TypeAt(intptr_t index) const; |
1321 static intptr_t type_at_offset(intptr_t index) { | 1330 static intptr_t type_at_offset(intptr_t index) { |
1322 return OFFSET_OF(RawTypeArguments, types_) + index * kWordSize; | 1331 return OFFSET_OF(RawTypeArguments, types_) + index * kWordSize; |
1323 } | 1332 } |
1324 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; | 1333 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; |
1325 virtual bool IsResolved() const; | 1334 virtual bool IsResolved() const; |
1326 virtual bool IsInstantiated() const; | 1335 virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const; |
1327 virtual bool IsUninstantiatedIdentity() const; | 1336 virtual bool IsUninstantiatedIdentity() const; |
1328 virtual bool CanShareInstantiatorTypeArguments( | 1337 virtual bool CanShareInstantiatorTypeArguments( |
1329 const Class& instantiator_class) const; | 1338 const Class& instantiator_class) const; |
1330 virtual bool IsFinalized() const; | 1339 virtual bool IsFinalized() const; |
1331 virtual bool IsBounded() const; | 1340 virtual bool IsBounded() const; |
1332 virtual RawAbstractTypeArguments* CloneUnfinalized() const; | 1341 virtual RawAbstractTypeArguments* CloneUnfinalized() const; |
1333 // Canonicalize only if instantiated, otherwise returns 'this'. | 1342 // Canonicalize only if instantiated, otherwise returns 'this'. |
1334 virtual RawAbstractTypeArguments* Canonicalize() const; | 1343 virtual RawAbstractTypeArguments* Canonicalize( |
| 1344 GrowableObjectArray* trail = NULL) const; |
1335 | 1345 |
1336 virtual RawAbstractTypeArguments* InstantiateFrom( | 1346 virtual RawAbstractTypeArguments* InstantiateFrom( |
1337 const AbstractTypeArguments& instantiator_type_arguments, | 1347 const AbstractTypeArguments& instantiator_type_arguments, |
1338 Error* bound_error) const; | 1348 Error* bound_error, |
| 1349 GrowableObjectArray* trail = NULL) const; |
1339 | 1350 |
1340 static const intptr_t kBytesPerElement = kWordSize; | 1351 static const intptr_t kBytesPerElement = kWordSize; |
1341 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 1352 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
1342 | 1353 |
1343 static intptr_t length_offset() { | 1354 static intptr_t length_offset() { |
1344 return OFFSET_OF(RawTypeArguments, length_); | 1355 return OFFSET_OF(RawTypeArguments, length_); |
1345 } | 1356 } |
1346 | 1357 |
1347 static intptr_t InstanceSize() { | 1358 static intptr_t InstanceSize() { |
1348 ASSERT(sizeof(RawTypeArguments) == OFFSET_OF(RawTypeArguments, types_)); | 1359 ASSERT(sizeof(RawTypeArguments) == OFFSET_OF(RawTypeArguments, types_)); |
(...skipping 28 matching lines...) Expand all Loading... |
1377 // one TypeParameter object, i.e. to a type that is not known at compile time. | 1388 // one TypeParameter object, i.e. to a type that is not known at compile time. |
1378 // The second type argument vector is the instantiator, because each type | 1389 // The second type argument vector is the instantiator, because each type |
1379 // parameter with index i in the first vector can be substituted (or | 1390 // parameter with index i in the first vector can be substituted (or |
1380 // "instantiated") with the type at index i in the second type argument vector. | 1391 // "instantiated") with the type at index i in the second type argument vector. |
1381 class InstantiatedTypeArguments : public AbstractTypeArguments { | 1392 class InstantiatedTypeArguments : public AbstractTypeArguments { |
1382 public: | 1393 public: |
1383 virtual intptr_t Length() const; | 1394 virtual intptr_t Length() const; |
1384 virtual RawAbstractType* TypeAt(intptr_t index) const; | 1395 virtual RawAbstractType* TypeAt(intptr_t index) const; |
1385 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; | 1396 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; |
1386 virtual bool IsResolved() const { return true; } | 1397 virtual bool IsResolved() const { return true; } |
1387 virtual bool IsInstantiated() const { return true; } | 1398 virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const { |
| 1399 return true; |
| 1400 } |
1388 virtual bool IsUninstantiatedIdentity() const { | 1401 virtual bool IsUninstantiatedIdentity() const { |
1389 UNREACHABLE(); | 1402 UNREACHABLE(); |
1390 return false; | 1403 return false; |
1391 } | 1404 } |
1392 virtual bool CanShareInstantiatorTypeArguments( | 1405 virtual bool CanShareInstantiatorTypeArguments( |
1393 const Class& instantiator_class) const { | 1406 const Class& instantiator_class) const { |
1394 UNREACHABLE(); | 1407 UNREACHABLE(); |
1395 return false; | 1408 return false; |
1396 } | 1409 } |
1397 virtual bool IsBounded() const { return false; } // Bounds were checked. | 1410 virtual bool IsBounded() const { return false; } // Bounds were checked. |
1398 virtual RawAbstractTypeArguments* Canonicalize() const; | 1411 virtual RawAbstractTypeArguments* Canonicalize( |
| 1412 GrowableObjectArray* trail = NULL) const; |
1399 | 1413 |
1400 RawAbstractTypeArguments* uninstantiated_type_arguments() const { | 1414 RawAbstractTypeArguments* uninstantiated_type_arguments() const { |
1401 return raw_ptr()->uninstantiated_type_arguments_; | 1415 return raw_ptr()->uninstantiated_type_arguments_; |
1402 } | 1416 } |
1403 static intptr_t uninstantiated_type_arguments_offset() { | 1417 static intptr_t uninstantiated_type_arguments_offset() { |
1404 return OFFSET_OF(RawInstantiatedTypeArguments, | 1418 return OFFSET_OF(RawInstantiatedTypeArguments, |
1405 uninstantiated_type_arguments_); | 1419 uninstantiated_type_arguments_); |
1406 } | 1420 } |
1407 | 1421 |
1408 RawAbstractTypeArguments* instantiator_type_arguments() const { | 1422 RawAbstractTypeArguments* instantiator_type_arguments() const { |
(...skipping 2670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4079 virtual bool IsMalbounded() const; | 4093 virtual bool IsMalbounded() const; |
4080 virtual bool IsMalformedOrMalbounded() const; | 4094 virtual bool IsMalformedOrMalbounded() const; |
4081 virtual RawLanguageError* error() const; | 4095 virtual RawLanguageError* error() const; |
4082 virtual void set_error(const LanguageError& value) const; | 4096 virtual void set_error(const LanguageError& value) const; |
4083 virtual bool IsResolved() const; | 4097 virtual bool IsResolved() const; |
4084 virtual bool HasResolvedTypeClass() const; | 4098 virtual bool HasResolvedTypeClass() const; |
4085 virtual RawClass* type_class() const; | 4099 virtual RawClass* type_class() const; |
4086 virtual RawUnresolvedClass* unresolved_class() const; | 4100 virtual RawUnresolvedClass* unresolved_class() const; |
4087 virtual RawAbstractTypeArguments* arguments() const; | 4101 virtual RawAbstractTypeArguments* arguments() const; |
4088 virtual intptr_t token_pos() const; | 4102 virtual intptr_t token_pos() const; |
4089 virtual bool IsInstantiated() const; | 4103 virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const; |
4090 virtual bool Equals(const Instance& other) const; | 4104 virtual bool Equals(const Instance& other) const { |
| 4105 return IsEquivalent(other); |
| 4106 } |
| 4107 virtual bool IsEquivalent(const Instance& other, |
| 4108 GrowableObjectArray* trail = NULL) const; |
4091 | 4109 |
4092 // Instantiate this type using the given type argument vector. | 4110 // Instantiate this type using the given type argument vector. |
4093 // Return a new type, or return 'this' if it is already instantiated. | 4111 // Return a new type, or return 'this' if it is already instantiated. |
4094 // If bound_error is not NULL, it may be set to reflect a bound error. | 4112 // If bound_error is not NULL, it may be set to reflect a bound error. |
4095 virtual RawAbstractType* InstantiateFrom( | 4113 virtual RawAbstractType* InstantiateFrom( |
4096 const AbstractTypeArguments& instantiator_type_arguments, | 4114 const AbstractTypeArguments& instantiator_type_arguments, |
4097 Error* bound_error) const; | 4115 Error* bound_error, |
| 4116 GrowableObjectArray* trail = NULL) const; |
4098 | 4117 |
4099 // Return a clone of this unfinalized type or the type itself if it is | 4118 // Return a clone of this unfinalized type or the type itself if it is |
4100 // already finalized. Apply recursively to type arguments, i.e. finalized | 4119 // already finalized. Apply recursively to type arguments, i.e. finalized |
4101 // type arguments of an unfinalized type are not cloned, but shared. | 4120 // type arguments of an unfinalized type are not cloned, but shared. |
4102 virtual RawAbstractType* CloneUnfinalized() const; | 4121 virtual RawAbstractType* CloneUnfinalized() const; |
4103 | 4122 |
4104 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const { | 4123 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const { |
4105 return Canonicalize(); | 4124 return Canonicalize(); |
4106 } | 4125 } |
4107 | 4126 |
4108 // Return the canonical version of this type. | 4127 // Return the canonical version of this type. |
4109 virtual RawAbstractType* Canonicalize() const; | 4128 virtual RawAbstractType* Canonicalize( |
| 4129 GrowableObjectArray* trail = NULL) const; |
4110 | 4130 |
4111 // The name of this type, including the names of its type arguments, if any. | 4131 // The name of this type, including the names of its type arguments, if any. |
4112 virtual RawString* Name() const { | 4132 virtual RawString* Name() const { |
4113 return BuildName(kInternalName); | 4133 return BuildName(kInternalName); |
4114 } | 4134 } |
4115 | 4135 |
4116 // The name of this type, including the names of its type arguments, if any. | 4136 // The name of this type, including the names of its type arguments, if any. |
4117 // Names of internal classes are mapped to their public interfaces. | 4137 // Names of internal classes are mapped to their public interfaces. |
4118 virtual RawString* UserVisibleName() const { | 4138 virtual RawString* UserVisibleName() const { |
4119 return BuildName(kUserVisibleName); | 4139 return BuildName(kUserVisibleName); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4225 virtual RawLanguageError* error() const { return raw_ptr()->error_; } | 4245 virtual RawLanguageError* error() const { return raw_ptr()->error_; } |
4226 virtual void set_error(const LanguageError& value) const; | 4246 virtual void set_error(const LanguageError& value) const; |
4227 virtual bool IsResolved() const; // Class and all arguments classes resolved. | 4247 virtual bool IsResolved() const; // Class and all arguments classes resolved. |
4228 virtual bool HasResolvedTypeClass() const; // Own type class resolved. | 4248 virtual bool HasResolvedTypeClass() const; // Own type class resolved. |
4229 virtual RawClass* type_class() const; | 4249 virtual RawClass* type_class() const; |
4230 void set_type_class(const Object& value) const; | 4250 void set_type_class(const Object& value) const; |
4231 virtual RawUnresolvedClass* unresolved_class() const; | 4251 virtual RawUnresolvedClass* unresolved_class() const; |
4232 virtual RawAbstractTypeArguments* arguments() const; | 4252 virtual RawAbstractTypeArguments* arguments() const; |
4233 void set_arguments(const AbstractTypeArguments& value) const; | 4253 void set_arguments(const AbstractTypeArguments& value) const; |
4234 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } | 4254 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
4235 virtual bool IsInstantiated() const; | 4255 virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const; |
4236 virtual bool Equals(const Instance& other) const; | 4256 virtual bool IsEquivalent(const Instance& other, |
| 4257 GrowableObjectArray* trail = NULL) const; |
4237 virtual RawAbstractType* InstantiateFrom( | 4258 virtual RawAbstractType* InstantiateFrom( |
4238 const AbstractTypeArguments& instantiator_type_arguments, | 4259 const AbstractTypeArguments& instantiator_type_arguments, |
4239 Error* malformed_error) const; | 4260 Error* malformed_error, |
| 4261 GrowableObjectArray* trail = NULL) const; |
4240 virtual RawAbstractType* CloneUnfinalized() const; | 4262 virtual RawAbstractType* CloneUnfinalized() const; |
4241 virtual RawAbstractType* Canonicalize() const; | 4263 virtual RawAbstractType* Canonicalize( |
| 4264 GrowableObjectArray* trail = NULL) const; |
4242 | 4265 |
4243 virtual intptr_t Hash() const; | 4266 virtual intptr_t Hash() const; |
4244 | 4267 |
4245 static intptr_t InstanceSize() { | 4268 static intptr_t InstanceSize() { |
4246 return RoundedAllocationSize(sizeof(RawType)); | 4269 return RoundedAllocationSize(sizeof(RawType)); |
4247 } | 4270 } |
4248 | 4271 |
4249 // The type of the literal 'null'. | 4272 // The type of the literal 'null'. |
4250 static RawType* NullType(); | 4273 static RawType* NullType(); |
4251 | 4274 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4336 void set_type(const AbstractType& value) const; | 4359 void set_type(const AbstractType& value) const; |
4337 virtual RawClass* type_class() const { | 4360 virtual RawClass* type_class() const { |
4338 return AbstractType::Handle(type()).type_class(); | 4361 return AbstractType::Handle(type()).type_class(); |
4339 } | 4362 } |
4340 virtual RawAbstractTypeArguments* arguments() const { | 4363 virtual RawAbstractTypeArguments* arguments() const { |
4341 return AbstractType::Handle(type()).arguments(); | 4364 return AbstractType::Handle(type()).arguments(); |
4342 } | 4365 } |
4343 virtual intptr_t token_pos() const { | 4366 virtual intptr_t token_pos() const { |
4344 return AbstractType::Handle(type()).token_pos(); | 4367 return AbstractType::Handle(type()).token_pos(); |
4345 } | 4368 } |
4346 virtual bool IsInstantiated() const; | 4369 virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const; |
4347 virtual bool Equals(const Instance& other) const; | 4370 virtual bool IsEquivalent(const Instance& other, |
| 4371 GrowableObjectArray* trail = NULL) const; |
4348 virtual RawAbstractType* InstantiateFrom( | 4372 virtual RawAbstractType* InstantiateFrom( |
4349 const AbstractTypeArguments& instantiator_type_arguments, | 4373 const AbstractTypeArguments& instantiator_type_arguments, |
4350 Error* bound_error) const; | 4374 Error* bound_error, |
4351 virtual RawAbstractType* Canonicalize() const; | 4375 GrowableObjectArray* trail = NULL) const; |
| 4376 virtual RawAbstractType* Canonicalize( |
| 4377 GrowableObjectArray* trail = NULL) const; |
4352 | 4378 |
4353 virtual intptr_t Hash() const; | 4379 virtual intptr_t Hash() const; |
4354 | 4380 |
| 4381 // Return true if the receiver is contained in the trail. |
| 4382 // Otherwise, if the trail is null, allocate a trail, then add the receiver to |
| 4383 // the trail and return false. |
| 4384 bool TestAndAddToTrail(GrowableObjectArray** trail) const; |
| 4385 |
| 4386 // Return true if the pair <receiver, buddy> is contained in the trail. |
| 4387 // Otherwise, if the trail is null, allocate a trail, add the pair <receiver, |
| 4388 // buddy> to the trail and return false. |
| 4389 // The receiver may be added several times, each time with a different buddy. |
| 4390 bool TestAndAddBuddyToTrail(GrowableObjectArray** trail, |
| 4391 const Object& buddy) const; |
| 4392 |
| 4393 // Return the object associated with the receiver in the trail or |
| 4394 // Object::null() if the receiver is not contained in the trail. |
| 4395 RawObject* OnlyBuddyInTrail(GrowableObjectArray* trail) const; |
| 4396 |
| 4397 // If the trail is null, allocate a trail, add the pair <receiver, buddy> to |
| 4398 // the trail. The receiver may only be added once with its only buddy. |
| 4399 void AddOnlyBuddyToTrail(GrowableObjectArray** trail, |
| 4400 const Object& buddy) const; |
| 4401 |
4355 static intptr_t InstanceSize() { | 4402 static intptr_t InstanceSize() { |
4356 return RoundedAllocationSize(sizeof(RawTypeRef)); | 4403 return RoundedAllocationSize(sizeof(RawTypeRef)); |
4357 } | 4404 } |
4358 | 4405 |
4359 static RawTypeRef* New(const AbstractType& type); | 4406 static RawTypeRef* New(const AbstractType& type); |
4360 | 4407 |
4361 private: | 4408 private: |
4362 bool is_being_checked() const { | |
4363 return raw_ptr()->is_being_checked_; | |
4364 } | |
4365 void set_is_being_checked(bool value) const; | |
4366 | |
4367 static RawTypeRef* New(); | 4409 static RawTypeRef* New(); |
4368 | 4410 |
4369 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeRef, AbstractType); | 4411 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeRef, AbstractType); |
4370 friend class Class; | 4412 friend class Class; |
4371 }; | 4413 }; |
4372 | 4414 |
4373 | 4415 |
4374 // A TypeParameter represents a type parameter of a parameterized class. | 4416 // A TypeParameter represents a type parameter of a parameterized class. |
4375 // It specifies its index (and its name for debugging purposes), as well as its | 4417 // It specifies its index (and its name for debugging purposes), as well as its |
4376 // upper bound. | 4418 // upper bound. |
(...skipping 26 matching lines...) Expand all Loading... |
4403 RawAbstractType* bound() const { return raw_ptr()->bound_; } | 4445 RawAbstractType* bound() const { return raw_ptr()->bound_; } |
4404 void set_bound(const AbstractType& value) const; | 4446 void set_bound(const AbstractType& value) const; |
4405 // Returns true if bounded_type is below upper_bound, otherwise return false | 4447 // Returns true if bounded_type is below upper_bound, otherwise return false |
4406 // and set bound_error if both bounded_type and upper_bound are instantiated. | 4448 // and set bound_error if both bounded_type and upper_bound are instantiated. |
4407 // If one or both are not instantiated, returning false only means that the | 4449 // If one or both are not instantiated, returning false only means that the |
4408 // bound cannot be checked yet and this is not an error. | 4450 // bound cannot be checked yet and this is not an error. |
4409 bool CheckBound(const AbstractType& bounded_type, | 4451 bool CheckBound(const AbstractType& bounded_type, |
4410 const AbstractType& upper_bound, | 4452 const AbstractType& upper_bound, |
4411 Error* bound_error) const; | 4453 Error* bound_error) const; |
4412 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } | 4454 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
4413 virtual bool IsInstantiated() const { return false; } | 4455 virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const { |
4414 virtual bool Equals(const Instance& other) const; | 4456 return false; |
| 4457 } |
| 4458 virtual bool IsEquivalent(const Instance& other, |
| 4459 GrowableObjectArray* trail = NULL) const; |
4415 virtual RawAbstractType* InstantiateFrom( | 4460 virtual RawAbstractType* InstantiateFrom( |
4416 const AbstractTypeArguments& instantiator_type_arguments, | 4461 const AbstractTypeArguments& instantiator_type_arguments, |
4417 Error* bound_error) const; | 4462 Error* bound_error, |
| 4463 GrowableObjectArray* trail = NULL) const; |
4418 virtual RawAbstractType* CloneUnfinalized() const; | 4464 virtual RawAbstractType* CloneUnfinalized() const; |
4419 virtual RawAbstractType* Canonicalize() const { return raw(); } | 4465 virtual RawAbstractType* Canonicalize( |
| 4466 GrowableObjectArray* trail = NULL) const { |
| 4467 return raw(); |
| 4468 } |
4420 | 4469 |
4421 virtual intptr_t Hash() const; | 4470 virtual intptr_t Hash() const; |
4422 | 4471 |
4423 static intptr_t InstanceSize() { | 4472 static intptr_t InstanceSize() { |
4424 return RoundedAllocationSize(sizeof(RawTypeParameter)); | 4473 return RoundedAllocationSize(sizeof(RawTypeParameter)); |
4425 } | 4474 } |
4426 | 4475 |
4427 static RawTypeParameter* New(const Class& parameterized_class, | 4476 static RawTypeParameter* New(const Class& parameterized_class, |
4428 intptr_t index, | 4477 intptr_t index, |
4429 const String& name, | 4478 const String& name, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4475 return AbstractType::Handle(type()).arguments(); | 4524 return AbstractType::Handle(type()).arguments(); |
4476 } | 4525 } |
4477 RawAbstractType* type() const { return raw_ptr()->type_; } | 4526 RawAbstractType* type() const { return raw_ptr()->type_; } |
4478 RawAbstractType* bound() const { return raw_ptr()->bound_; } | 4527 RawAbstractType* bound() const { return raw_ptr()->bound_; } |
4479 RawTypeParameter* type_parameter() const { | 4528 RawTypeParameter* type_parameter() const { |
4480 return raw_ptr()->type_parameter_; | 4529 return raw_ptr()->type_parameter_; |
4481 } | 4530 } |
4482 virtual intptr_t token_pos() const { | 4531 virtual intptr_t token_pos() const { |
4483 return AbstractType::Handle(type()).token_pos(); | 4532 return AbstractType::Handle(type()).token_pos(); |
4484 } | 4533 } |
4485 virtual bool IsInstantiated() const { | 4534 virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const { |
4486 // It is not possible to encounter an instantiated bounded type with an | 4535 // It is not possible to encounter an instantiated bounded type with an |
4487 // uninstantiated upper bound. Therefore, we do not need to check if the | 4536 // uninstantiated upper bound. Therefore, we do not need to check if the |
4488 // bound is instantiated. Moreover, doing so could lead into cycles, as in | 4537 // bound is instantiated. Moreover, doing so could lead into cycles, as in |
4489 // class C<T extends C<C>> { }. | 4538 // class C<T extends C<C>> { }. |
4490 return AbstractType::Handle(type()).IsInstantiated(); | 4539 return AbstractType::Handle(type()).IsInstantiated(); |
4491 } | 4540 } |
4492 virtual bool Equals(const Instance& other) const; | 4541 virtual bool IsEquivalent(const Instance& other, |
| 4542 GrowableObjectArray* trail = NULL) const; |
4493 virtual RawAbstractType* InstantiateFrom( | 4543 virtual RawAbstractType* InstantiateFrom( |
4494 const AbstractTypeArguments& instantiator_type_arguments, | 4544 const AbstractTypeArguments& instantiator_type_arguments, |
4495 Error* bound_error) const; | 4545 Error* bound_error, |
| 4546 GrowableObjectArray* trail = NULL) const; |
4496 virtual RawAbstractType* CloneUnfinalized() const; | 4547 virtual RawAbstractType* CloneUnfinalized() const; |
4497 virtual RawAbstractType* Canonicalize() const { return raw(); } | 4548 virtual RawAbstractType* Canonicalize( |
| 4549 GrowableObjectArray* trail = NULL) const { |
| 4550 return raw(); |
| 4551 } |
4498 | 4552 |
4499 virtual intptr_t Hash() const; | 4553 virtual intptr_t Hash() const; |
4500 | 4554 |
4501 static intptr_t InstanceSize() { | 4555 static intptr_t InstanceSize() { |
4502 return RoundedAllocationSize(sizeof(RawBoundedType)); | 4556 return RoundedAllocationSize(sizeof(RawBoundedType)); |
4503 } | 4557 } |
4504 | 4558 |
4505 static RawBoundedType* New(const AbstractType& type, | 4559 static RawBoundedType* New(const AbstractType& type, |
4506 const AbstractType& bound, | 4560 const AbstractType& bound, |
4507 const TypeParameter& type_parameter); | 4561 const TypeParameter& type_parameter); |
4508 | 4562 |
4509 private: | 4563 private: |
4510 void set_type(const AbstractType& value) const; | 4564 void set_type(const AbstractType& value) const; |
4511 void set_bound(const AbstractType& value) const; | 4565 void set_bound(const AbstractType& value) const; |
4512 void set_type_parameter(const TypeParameter& value) const; | 4566 void set_type_parameter(const TypeParameter& value) const; |
4513 | 4567 |
4514 bool is_being_checked() const { | |
4515 return raw_ptr()->is_being_checked_; | |
4516 } | |
4517 void set_is_being_checked(bool value) const; | |
4518 | |
4519 static RawBoundedType* New(); | 4568 static RawBoundedType* New(); |
4520 | 4569 |
4521 FINAL_HEAP_OBJECT_IMPLEMENTATION(BoundedType, AbstractType); | 4570 FINAL_HEAP_OBJECT_IMPLEMENTATION(BoundedType, AbstractType); |
4522 friend class Class; | 4571 friend class Class; |
4523 }; | 4572 }; |
4524 | 4573 |
4525 | 4574 |
4526 // A MixinAppType represents a parsed mixin application clause, e.g. | 4575 // A MixinAppType represents a parsed mixin application clause, e.g. |
4527 // "S<T> with M<U>, N<V>". | 4576 // "S<T> with M<U>, N<V>". |
4528 // MixinAppType objects do not survive finalization, so they do not | 4577 // MixinAppType objects do not survive finalization, so they do not |
(...skipping 2053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6582 | 6631 |
6583 | 6632 |
6584 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6633 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
6585 intptr_t index) { | 6634 intptr_t index) { |
6586 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6635 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
6587 } | 6636 } |
6588 | 6637 |
6589 } // namespace dart | 6638 } // namespace dart |
6590 | 6639 |
6591 #endif // VM_OBJECT_H_ | 6640 #endif // VM_OBJECT_H_ |
OLD | NEW |