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 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1194 // Returns true if all types of this vector are finalized. | 1194 // Returns true if all types of this vector are finalized. |
1195 virtual bool IsFinalized() const { return true; } | 1195 virtual bool IsFinalized() const { return true; } |
1196 | 1196 |
1197 // Return 'this' if this type argument vector is instantiated, i.e. if it does | 1197 // Return 'this' if this type argument vector is instantiated, i.e. if it does |
1198 // not refer to type parameters. Otherwise, return a new type argument vector | 1198 // not refer to type parameters. Otherwise, return a new type argument vector |
1199 // where each reference to a type parameter is replaced with the corresponding | 1199 // where each reference to a type parameter is replaced with the corresponding |
1200 // type of the instantiator type argument vector. | 1200 // type of the instantiator type argument vector. |
1201 // If bound_error is not NULL, it may be set to reflect a bound error. | 1201 // If bound_error is not NULL, it may be set to reflect a bound error. |
1202 virtual RawAbstractTypeArguments* InstantiateFrom( | 1202 virtual RawAbstractTypeArguments* InstantiateFrom( |
1203 const AbstractTypeArguments& instantiator_type_arguments, | 1203 const AbstractTypeArguments& instantiator_type_arguments, |
1204 Error* bound_error) const; | 1204 Error* bound_error, |
1205 GrowableObjectArray* trail = NULL) const; | |
1205 | 1206 |
1206 // Do not clone InstantiatedTypeArguments or null vectors, since they are | 1207 // Do not clone InstantiatedTypeArguments or null vectors, since they are |
1207 // considered finalized. | 1208 // considered finalized. |
1208 virtual RawAbstractTypeArguments* CloneUnfinalized() const { | 1209 virtual RawAbstractTypeArguments* CloneUnfinalized() const { |
1209 return this->raw(); | 1210 return this->raw(); |
1210 } | 1211 } |
1211 | 1212 |
1212 // Do not canonicalize InstantiatedTypeArguments or null vectors. | 1213 // Do not canonicalize InstantiatedTypeArguments or null vectors. |
1213 virtual RawAbstractTypeArguments* Canonicalize() const { return this->raw(); } | 1214 virtual RawAbstractTypeArguments* Canonicalize( |
1215 GrowableObjectArray* trail = NULL) const { | |
1216 return this->raw(); | |
1217 } | |
1214 | 1218 |
1215 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, Smi>". | 1219 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, Smi>". |
1216 virtual RawString* Name() const { | 1220 virtual RawString* Name() const { |
1217 return SubvectorName(0, Length(), kInternalName); | 1221 return SubvectorName(0, Length(), kInternalName); |
1218 } | 1222 } |
1219 | 1223 |
1220 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, int>". | 1224 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, int>". |
1221 // Names of internal classes are mapped to their public interfaces. | 1225 // Names of internal classes are mapped to their public interfaces. |
1222 virtual RawString* UserVisibleName() const { | 1226 virtual RawString* UserVisibleName() const { |
1223 return SubvectorName(0, Length(), kUserVisibleName); | 1227 return SubvectorName(0, Length(), kUserVisibleName); |
(...skipping 25 matching lines...) Expand all Loading... | |
1249 // Check the 'more specific' relationship, considering only a subvector of | 1253 // Check the 'more specific' relationship, considering only a subvector of |
1250 // length 'len' starting at 'from_index'. | 1254 // length 'len' starting at 'from_index'. |
1251 bool IsMoreSpecificThan(const AbstractTypeArguments& other, | 1255 bool IsMoreSpecificThan(const AbstractTypeArguments& other, |
1252 intptr_t from_index, | 1256 intptr_t from_index, |
1253 intptr_t len, | 1257 intptr_t len, |
1254 Error* bound_error) const { | 1258 Error* bound_error) const { |
1255 return TypeTest(kIsMoreSpecificThan, other, from_index, len, bound_error); | 1259 return TypeTest(kIsMoreSpecificThan, other, from_index, len, bound_error); |
1256 } | 1260 } |
1257 | 1261 |
1258 // Check if the vectors are equal. | 1262 // Check if the vectors are equal. |
1259 bool Equals(const AbstractTypeArguments& other) const; | 1263 bool Equals(const AbstractTypeArguments& other) const { |
1264 return IsEquivalent(other); | |
1265 } | |
1266 | |
1267 bool IsEquivalent(const AbstractTypeArguments& other, | |
1268 GrowableObjectArray* trail = NULL) const; | |
1260 | 1269 |
1261 // UNREACHABLEs as AbstractTypeArguments is an abstract class. | 1270 // UNREACHABLEs as AbstractTypeArguments is an abstract class. |
1262 virtual intptr_t Length() const; | 1271 virtual intptr_t Length() const; |
1263 virtual RawAbstractType* TypeAt(intptr_t index) const; | 1272 virtual RawAbstractType* TypeAt(intptr_t index) const; |
1264 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; | 1273 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; |
1265 virtual bool IsResolved() const; | 1274 virtual bool IsResolved() const; |
1266 virtual bool IsInstantiated() const; | 1275 virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const; |
1267 virtual bool IsUninstantiatedIdentity() const; | 1276 virtual bool IsUninstantiatedIdentity() const; |
1268 virtual bool CanShareInstantiatorTypeArguments( | 1277 virtual bool CanShareInstantiatorTypeArguments( |
1269 const Class& instantiator_class) const; | 1278 const Class& instantiator_class) const; |
1270 virtual bool IsBounded() const; | 1279 virtual bool IsBounded() const; |
1271 | 1280 |
1272 virtual intptr_t Hash() const; | 1281 virtual intptr_t Hash() const; |
1273 | 1282 |
1274 private: | 1283 private: |
1275 // Check if the subvector of length 'len' starting at 'from_index' of this | 1284 // Check if the subvector of length 'len' starting at 'from_index' of this |
1276 // type argument vector consists solely of DynamicType. | 1285 // type argument vector consists solely of DynamicType. |
(...skipping 27 matching lines...) Expand all Loading... | |
1304 // A TypeArguments is an array of AbstractType. | 1313 // A TypeArguments is an array of AbstractType. |
1305 class TypeArguments : public AbstractTypeArguments { | 1314 class TypeArguments : public AbstractTypeArguments { |
1306 public: | 1315 public: |
1307 virtual intptr_t Length() const; | 1316 virtual intptr_t Length() const; |
1308 virtual RawAbstractType* TypeAt(intptr_t index) const; | 1317 virtual RawAbstractType* TypeAt(intptr_t index) const; |
1309 static intptr_t type_at_offset(intptr_t index) { | 1318 static intptr_t type_at_offset(intptr_t index) { |
1310 return OFFSET_OF(RawTypeArguments, types_) + index * kWordSize; | 1319 return OFFSET_OF(RawTypeArguments, types_) + index * kWordSize; |
1311 } | 1320 } |
1312 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; | 1321 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; |
1313 virtual bool IsResolved() const; | 1322 virtual bool IsResolved() const; |
1314 virtual bool IsInstantiated() const; | 1323 virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const; |
1315 virtual bool IsUninstantiatedIdentity() const; | 1324 virtual bool IsUninstantiatedIdentity() const; |
1316 virtual bool CanShareInstantiatorTypeArguments( | 1325 virtual bool CanShareInstantiatorTypeArguments( |
1317 const Class& instantiator_class) const; | 1326 const Class& instantiator_class) const; |
1318 virtual bool IsFinalized() const; | 1327 virtual bool IsFinalized() const; |
1319 virtual bool IsBounded() const; | 1328 virtual bool IsBounded() const; |
1320 virtual RawAbstractTypeArguments* CloneUnfinalized() const; | 1329 virtual RawAbstractTypeArguments* CloneUnfinalized() const; |
1321 // Canonicalize only if instantiated, otherwise returns 'this'. | 1330 // Canonicalize only if instantiated, otherwise returns 'this'. |
1322 virtual RawAbstractTypeArguments* Canonicalize() const; | 1331 virtual RawAbstractTypeArguments* Canonicalize( |
1332 GrowableObjectArray* trail = NULL) const; | |
1323 | 1333 |
1324 virtual RawAbstractTypeArguments* InstantiateFrom( | 1334 virtual RawAbstractTypeArguments* InstantiateFrom( |
1325 const AbstractTypeArguments& instantiator_type_arguments, | 1335 const AbstractTypeArguments& instantiator_type_arguments, |
1326 Error* bound_error) const; | 1336 Error* bound_error, |
1337 GrowableObjectArray* trail = NULL) const; | |
1327 | 1338 |
1328 static const intptr_t kBytesPerElement = kWordSize; | 1339 static const intptr_t kBytesPerElement = kWordSize; |
1329 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 1340 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
1330 | 1341 |
1331 static intptr_t length_offset() { | 1342 static intptr_t length_offset() { |
1332 return OFFSET_OF(RawTypeArguments, length_); | 1343 return OFFSET_OF(RawTypeArguments, length_); |
1333 } | 1344 } |
1334 | 1345 |
1335 static intptr_t InstanceSize() { | 1346 static intptr_t InstanceSize() { |
1336 ASSERT(sizeof(RawTypeArguments) == OFFSET_OF(RawTypeArguments, types_)); | 1347 ASSERT(sizeof(RawTypeArguments) == OFFSET_OF(RawTypeArguments, types_)); |
(...skipping 28 matching lines...) Expand all Loading... | |
1365 // one TypeParameter object, i.e. to a type that is not known at compile time. | 1376 // one TypeParameter object, i.e. to a type that is not known at compile time. |
1366 // The second type argument vector is the instantiator, because each type | 1377 // The second type argument vector is the instantiator, because each type |
1367 // parameter with index i in the first vector can be substituted (or | 1378 // parameter with index i in the first vector can be substituted (or |
1368 // "instantiated") with the type at index i in the second type argument vector. | 1379 // "instantiated") with the type at index i in the second type argument vector. |
1369 class InstantiatedTypeArguments : public AbstractTypeArguments { | 1380 class InstantiatedTypeArguments : public AbstractTypeArguments { |
1370 public: | 1381 public: |
1371 virtual intptr_t Length() const; | 1382 virtual intptr_t Length() const; |
1372 virtual RawAbstractType* TypeAt(intptr_t index) const; | 1383 virtual RawAbstractType* TypeAt(intptr_t index) const; |
1373 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; | 1384 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; |
1374 virtual bool IsResolved() const { return true; } | 1385 virtual bool IsResolved() const { return true; } |
1375 virtual bool IsInstantiated() const { return true; } | 1386 virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const { |
1387 return true; | |
1388 } | |
1376 virtual bool IsUninstantiatedIdentity() const { | 1389 virtual bool IsUninstantiatedIdentity() const { |
1377 UNREACHABLE(); | 1390 UNREACHABLE(); |
1378 return false; | 1391 return false; |
1379 } | 1392 } |
1380 virtual bool CanShareInstantiatorTypeArguments( | 1393 virtual bool CanShareInstantiatorTypeArguments( |
1381 const Class& instantiator_class) const { | 1394 const Class& instantiator_class) const { |
1382 UNREACHABLE(); | 1395 UNREACHABLE(); |
1383 return false; | 1396 return false; |
1384 } | 1397 } |
1385 virtual bool IsBounded() const { return false; } // Bounds were checked. | 1398 virtual bool IsBounded() const { return false; } // Bounds were checked. |
(...skipping 2676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4062 virtual bool IsMalbounded() const; | 4075 virtual bool IsMalbounded() const; |
4063 virtual bool IsMalformedOrMalbounded() const; | 4076 virtual bool IsMalformedOrMalbounded() const; |
4064 virtual RawLanguageError* error() const; | 4077 virtual RawLanguageError* error() const; |
4065 virtual void set_error(const LanguageError& value) const; | 4078 virtual void set_error(const LanguageError& value) const; |
4066 virtual bool IsResolved() const; | 4079 virtual bool IsResolved() const; |
4067 virtual bool HasResolvedTypeClass() const; | 4080 virtual bool HasResolvedTypeClass() const; |
4068 virtual RawClass* type_class() const; | 4081 virtual RawClass* type_class() const; |
4069 virtual RawUnresolvedClass* unresolved_class() const; | 4082 virtual RawUnresolvedClass* unresolved_class() const; |
4070 virtual RawAbstractTypeArguments* arguments() const; | 4083 virtual RawAbstractTypeArguments* arguments() const; |
4071 virtual intptr_t token_pos() const; | 4084 virtual intptr_t token_pos() const; |
4072 virtual bool IsInstantiated() const; | 4085 virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const; |
4073 virtual bool Equals(const Instance& other) const; | 4086 virtual bool Equals(const Instance& other) const { |
4087 return IsEquivalent(other); | |
4088 } | |
4089 virtual bool IsEquivalent(const Instance& other, | |
4090 GrowableObjectArray* trail = NULL) const; | |
4074 | 4091 |
4075 // Instantiate this type using the given type argument vector. | 4092 // Instantiate this type using the given type argument vector. |
4076 // Return a new type, or return 'this' if it is already instantiated. | 4093 // Return a new type, or return 'this' if it is already instantiated. |
4077 // If bound_error is not NULL, it may be set to reflect a bound error. | 4094 // If bound_error is not NULL, it may be set to reflect a bound error. |
4078 virtual RawAbstractType* InstantiateFrom( | 4095 virtual RawAbstractType* InstantiateFrom( |
4079 const AbstractTypeArguments& instantiator_type_arguments, | 4096 const AbstractTypeArguments& instantiator_type_arguments, |
4080 Error* bound_error) const; | 4097 Error* bound_error, |
4098 GrowableObjectArray* trail = NULL) const; | |
4081 | 4099 |
4082 // Return a clone of this unfinalized type or the type itself if it is | 4100 // Return a clone of this unfinalized type or the type itself if it is |
4083 // already finalized. Apply recursively to type arguments, i.e. finalized | 4101 // already finalized. Apply recursively to type arguments, i.e. finalized |
4084 // type arguments of an unfinalized type are not cloned, but shared. | 4102 // type arguments of an unfinalized type are not cloned, but shared. |
4085 virtual RawAbstractType* CloneUnfinalized() const; | 4103 virtual RawAbstractType* CloneUnfinalized() const; |
4086 | 4104 |
4087 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const { | 4105 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const { |
4088 return Canonicalize(); | 4106 return Canonicalize(); |
4089 } | 4107 } |
4090 | 4108 |
4091 // Return the canonical version of this type. | 4109 // Return the canonical version of this type. |
4092 virtual RawAbstractType* Canonicalize() const; | 4110 virtual RawAbstractType* Canonicalize( |
4111 GrowableObjectArray* trail = NULL) const; | |
4093 | 4112 |
4094 // The name of this type, including the names of its type arguments, if any. | 4113 // The name of this type, including the names of its type arguments, if any. |
4095 virtual RawString* Name() const { | 4114 virtual RawString* Name() const { |
4096 return BuildName(kInternalName); | 4115 return BuildName(kInternalName); |
4097 } | 4116 } |
4098 | 4117 |
4099 // The name of this type, including the names of its type arguments, if any. | 4118 // The name of this type, including the names of its type arguments, if any. |
4100 // Names of internal classes are mapped to their public interfaces. | 4119 // Names of internal classes are mapped to their public interfaces. |
4101 virtual RawString* UserVisibleName() const { | 4120 virtual RawString* UserVisibleName() const { |
4102 return BuildName(kUserVisibleName); | 4121 return BuildName(kUserVisibleName); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4208 virtual RawLanguageError* error() const { return raw_ptr()->error_; } | 4227 virtual RawLanguageError* error() const { return raw_ptr()->error_; } |
4209 virtual void set_error(const LanguageError& value) const; | 4228 virtual void set_error(const LanguageError& value) const; |
4210 virtual bool IsResolved() const; // Class and all arguments classes resolved. | 4229 virtual bool IsResolved() const; // Class and all arguments classes resolved. |
4211 virtual bool HasResolvedTypeClass() const; // Own type class resolved. | 4230 virtual bool HasResolvedTypeClass() const; // Own type class resolved. |
4212 virtual RawClass* type_class() const; | 4231 virtual RawClass* type_class() const; |
4213 void set_type_class(const Object& value) const; | 4232 void set_type_class(const Object& value) const; |
4214 virtual RawUnresolvedClass* unresolved_class() const; | 4233 virtual RawUnresolvedClass* unresolved_class() const; |
4215 virtual RawAbstractTypeArguments* arguments() const; | 4234 virtual RawAbstractTypeArguments* arguments() const; |
4216 void set_arguments(const AbstractTypeArguments& value) const; | 4235 void set_arguments(const AbstractTypeArguments& value) const; |
4217 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } | 4236 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
4218 virtual bool IsInstantiated() const; | 4237 virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const; |
4219 virtual bool Equals(const Instance& other) const; | 4238 virtual bool IsEquivalent(const Instance& other, |
4239 GrowableObjectArray* trail = NULL) const; | |
4220 virtual RawAbstractType* InstantiateFrom( | 4240 virtual RawAbstractType* InstantiateFrom( |
4221 const AbstractTypeArguments& instantiator_type_arguments, | 4241 const AbstractTypeArguments& instantiator_type_arguments, |
4222 Error* malformed_error) const; | 4242 Error* malformed_error, |
4243 GrowableObjectArray* trail = NULL) const; | |
4223 virtual RawAbstractType* CloneUnfinalized() const; | 4244 virtual RawAbstractType* CloneUnfinalized() const; |
4224 virtual RawAbstractType* Canonicalize() const; | 4245 virtual RawAbstractType* Canonicalize( |
4246 GrowableObjectArray* trail = NULL) const; | |
4225 | 4247 |
4226 virtual intptr_t Hash() const; | 4248 virtual intptr_t Hash() const; |
4227 | 4249 |
4228 static intptr_t InstanceSize() { | 4250 static intptr_t InstanceSize() { |
4229 return RoundedAllocationSize(sizeof(RawType)); | 4251 return RoundedAllocationSize(sizeof(RawType)); |
4230 } | 4252 } |
4231 | 4253 |
4232 // The type of the literal 'null'. | 4254 // The type of the literal 'null'. |
4233 static RawType* NullType(); | 4255 static RawType* NullType(); |
4234 | 4256 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4319 void set_type(const AbstractType& value) const; | 4341 void set_type(const AbstractType& value) const; |
4320 virtual RawClass* type_class() const { | 4342 virtual RawClass* type_class() const { |
4321 return AbstractType::Handle(type()).type_class(); | 4343 return AbstractType::Handle(type()).type_class(); |
4322 } | 4344 } |
4323 virtual RawAbstractTypeArguments* arguments() const { | 4345 virtual RawAbstractTypeArguments* arguments() const { |
4324 return AbstractType::Handle(type()).arguments(); | 4346 return AbstractType::Handle(type()).arguments(); |
4325 } | 4347 } |
4326 virtual intptr_t token_pos() const { | 4348 virtual intptr_t token_pos() const { |
4327 return AbstractType::Handle(type()).token_pos(); | 4349 return AbstractType::Handle(type()).token_pos(); |
4328 } | 4350 } |
4329 virtual bool IsInstantiated() const; | 4351 virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const; |
4330 virtual bool Equals(const Instance& other) const; | 4352 virtual bool IsEquivalent(const Instance& other, |
4353 GrowableObjectArray* trail = NULL) const; | |
4331 virtual RawAbstractType* InstantiateFrom( | 4354 virtual RawAbstractType* InstantiateFrom( |
4332 const AbstractTypeArguments& instantiator_type_arguments, | 4355 const AbstractTypeArguments& instantiator_type_arguments, |
4333 Error* bound_error) const; | 4356 Error* bound_error, |
4334 virtual RawAbstractType* Canonicalize() const; | 4357 GrowableObjectArray* trail = NULL) const; |
4358 virtual RawAbstractType* Canonicalize( | |
4359 GrowableObjectArray* trail = NULL) const; | |
4335 | 4360 |
4336 virtual intptr_t Hash() const; | 4361 virtual intptr_t Hash() const; |
4337 | 4362 |
4363 // Return true if the receiver is contained in the trail. | |
4364 // Otherwise, if the trail is null, allocate a trail, then add the receiver to | |
4365 // the trail and return false. | |
4366 bool TestAndAddToTrail(GrowableObjectArray** trail) const; | |
4367 | |
4368 // Return true if the pair <receiver, buddy> is contained in the trail. | |
4369 // Otherwise, if the trail is null, allocate a trail, add the pair <receiver, | |
4370 // buddy> to the trail and return false. | |
4371 bool TestAndAddBuddyToTrail(GrowableObjectArray** trail, | |
4372 const Object& buddy) const; | |
4373 | |
4374 // Return the object associated with the receiver in the trail or | |
4375 // Object::null() if the receiver is not contained in the trail. | |
4376 RawObject* BuddyInTrail(GrowableObjectArray* trail) const; | |
4377 | |
4378 // If the trail is null, allocate a trail, add the pair <receiver, buddy> to | |
4379 // the trail. | |
siva
2013/12/20 19:35:10
Comment does not indicate what happens if the rece
regis
2014/01/07 20:26:27
I added a comment and renamed the call to AddOnlyB
| |
4380 void AddBuddyToTrail(GrowableObjectArray** trail, const Object& buddy) const; | |
4381 | |
4338 static intptr_t InstanceSize() { | 4382 static intptr_t InstanceSize() { |
4339 return RoundedAllocationSize(sizeof(RawTypeRef)); | 4383 return RoundedAllocationSize(sizeof(RawTypeRef)); |
4340 } | 4384 } |
4341 | 4385 |
4342 static RawTypeRef* New(const AbstractType& type); | 4386 static RawTypeRef* New(const AbstractType& type); |
4343 | 4387 |
4344 private: | 4388 private: |
4345 bool is_being_checked() const { | |
4346 return raw_ptr()->is_being_checked_; | |
4347 } | |
4348 void set_is_being_checked(bool value) const; | |
4349 | |
4350 static RawTypeRef* New(); | 4389 static RawTypeRef* New(); |
4351 | 4390 |
4352 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeRef, AbstractType); | 4391 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeRef, AbstractType); |
4353 friend class Class; | 4392 friend class Class; |
4354 }; | 4393 }; |
4355 | 4394 |
4356 | 4395 |
4357 // A TypeParameter represents a type parameter of a parameterized class. | 4396 // A TypeParameter represents a type parameter of a parameterized class. |
4358 // It specifies its index (and its name for debugging purposes), as well as its | 4397 // It specifies its index (and its name for debugging purposes), as well as its |
4359 // upper bound. | 4398 // upper bound. |
(...skipping 26 matching lines...) Expand all Loading... | |
4386 RawAbstractType* bound() const { return raw_ptr()->bound_; } | 4425 RawAbstractType* bound() const { return raw_ptr()->bound_; } |
4387 void set_bound(const AbstractType& value) const; | 4426 void set_bound(const AbstractType& value) const; |
4388 // Returns true if bounded_type is below upper_bound, otherwise return false | 4427 // Returns true if bounded_type is below upper_bound, otherwise return false |
4389 // and set bound_error if both bounded_type and upper_bound are instantiated. | 4428 // and set bound_error if both bounded_type and upper_bound are instantiated. |
4390 // If one or both are not instantiated, returning false only means that the | 4429 // If one or both are not instantiated, returning false only means that the |
4391 // bound cannot be checked yet and this is not an error. | 4430 // bound cannot be checked yet and this is not an error. |
4392 bool CheckBound(const AbstractType& bounded_type, | 4431 bool CheckBound(const AbstractType& bounded_type, |
4393 const AbstractType& upper_bound, | 4432 const AbstractType& upper_bound, |
4394 Error* bound_error) const; | 4433 Error* bound_error) const; |
4395 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } | 4434 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
4396 virtual bool IsInstantiated() const { return false; } | 4435 virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const { |
4397 virtual bool Equals(const Instance& other) const; | 4436 return false; |
4437 } | |
4438 virtual bool IsEquivalent(const Instance& other, | |
4439 GrowableObjectArray* trail = NULL) const; | |
4398 virtual RawAbstractType* InstantiateFrom( | 4440 virtual RawAbstractType* InstantiateFrom( |
4399 const AbstractTypeArguments& instantiator_type_arguments, | 4441 const AbstractTypeArguments& instantiator_type_arguments, |
4400 Error* bound_error) const; | 4442 Error* bound_error, |
4443 GrowableObjectArray* trail = NULL) const; | |
4401 virtual RawAbstractType* CloneUnfinalized() const; | 4444 virtual RawAbstractType* CloneUnfinalized() const; |
4402 virtual RawAbstractType* Canonicalize() const { return raw(); } | 4445 virtual RawAbstractType* Canonicalize( |
4446 GrowableObjectArray* trail = NULL) const { | |
4447 return raw(); | |
4448 } | |
4403 | 4449 |
4404 virtual intptr_t Hash() const; | 4450 virtual intptr_t Hash() const; |
4405 | 4451 |
4406 static intptr_t InstanceSize() { | 4452 static intptr_t InstanceSize() { |
4407 return RoundedAllocationSize(sizeof(RawTypeParameter)); | 4453 return RoundedAllocationSize(sizeof(RawTypeParameter)); |
4408 } | 4454 } |
4409 | 4455 |
4410 static RawTypeParameter* New(const Class& parameterized_class, | 4456 static RawTypeParameter* New(const Class& parameterized_class, |
4411 intptr_t index, | 4457 intptr_t index, |
4412 const String& name, | 4458 const String& name, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4458 return AbstractType::Handle(type()).arguments(); | 4504 return AbstractType::Handle(type()).arguments(); |
4459 } | 4505 } |
4460 RawAbstractType* type() const { return raw_ptr()->type_; } | 4506 RawAbstractType* type() const { return raw_ptr()->type_; } |
4461 RawAbstractType* bound() const { return raw_ptr()->bound_; } | 4507 RawAbstractType* bound() const { return raw_ptr()->bound_; } |
4462 RawTypeParameter* type_parameter() const { | 4508 RawTypeParameter* type_parameter() const { |
4463 return raw_ptr()->type_parameter_; | 4509 return raw_ptr()->type_parameter_; |
4464 } | 4510 } |
4465 virtual intptr_t token_pos() const { | 4511 virtual intptr_t token_pos() const { |
4466 return AbstractType::Handle(type()).token_pos(); | 4512 return AbstractType::Handle(type()).token_pos(); |
4467 } | 4513 } |
4468 virtual bool IsInstantiated() const { | 4514 virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const { |
4469 // It is not possible to encounter an instantiated bounded type with an | 4515 // It is not possible to encounter an instantiated bounded type with an |
4470 // uninstantiated upper bound. Therefore, we do not need to check if the | 4516 // uninstantiated upper bound. Therefore, we do not need to check if the |
4471 // bound is instantiated. Moreover, doing so could lead into cycles, as in | 4517 // bound is instantiated. Moreover, doing so could lead into cycles, as in |
4472 // class C<T extends C<C>> { }. | 4518 // class C<T extends C<C>> { }. |
4473 return AbstractType::Handle(type()).IsInstantiated(); | 4519 return AbstractType::Handle(type()).IsInstantiated(); |
4474 } | 4520 } |
4475 virtual bool Equals(const Instance& other) const; | 4521 virtual bool IsEquivalent(const Instance& other, |
4522 GrowableObjectArray* trail = NULL) const; | |
4476 virtual RawAbstractType* InstantiateFrom( | 4523 virtual RawAbstractType* InstantiateFrom( |
4477 const AbstractTypeArguments& instantiator_type_arguments, | 4524 const AbstractTypeArguments& instantiator_type_arguments, |
4478 Error* bound_error) const; | 4525 Error* bound_error, |
4526 GrowableObjectArray* trail = NULL) const; | |
4479 virtual RawAbstractType* CloneUnfinalized() const; | 4527 virtual RawAbstractType* CloneUnfinalized() const; |
4480 virtual RawAbstractType* Canonicalize() const { return raw(); } | 4528 virtual RawAbstractType* Canonicalize( |
4529 GrowableObjectArray* trail = NULL) const { | |
4530 return raw(); | |
4531 } | |
4481 | 4532 |
4482 virtual intptr_t Hash() const; | 4533 virtual intptr_t Hash() const; |
4483 | 4534 |
4484 static intptr_t InstanceSize() { | 4535 static intptr_t InstanceSize() { |
4485 return RoundedAllocationSize(sizeof(RawBoundedType)); | 4536 return RoundedAllocationSize(sizeof(RawBoundedType)); |
4486 } | 4537 } |
4487 | 4538 |
4488 static RawBoundedType* New(const AbstractType& type, | 4539 static RawBoundedType* New(const AbstractType& type, |
4489 const AbstractType& bound, | 4540 const AbstractType& bound, |
4490 const TypeParameter& type_parameter); | 4541 const TypeParameter& type_parameter); |
4491 | 4542 |
4492 private: | 4543 private: |
4493 void set_type(const AbstractType& value) const; | 4544 void set_type(const AbstractType& value) const; |
4494 void set_bound(const AbstractType& value) const; | 4545 void set_bound(const AbstractType& value) const; |
4495 void set_type_parameter(const TypeParameter& value) const; | 4546 void set_type_parameter(const TypeParameter& value) const; |
4496 | 4547 |
4497 bool is_being_checked() const { | |
4498 return raw_ptr()->is_being_checked_; | |
4499 } | |
4500 void set_is_being_checked(bool value) const; | |
4501 | |
4502 static RawBoundedType* New(); | 4548 static RawBoundedType* New(); |
4503 | 4549 |
4504 FINAL_HEAP_OBJECT_IMPLEMENTATION(BoundedType, AbstractType); | 4550 FINAL_HEAP_OBJECT_IMPLEMENTATION(BoundedType, AbstractType); |
4505 friend class Class; | 4551 friend class Class; |
4506 }; | 4552 }; |
4507 | 4553 |
4508 | 4554 |
4509 // A MixinAppType represents a parsed mixin application clause, e.g. | 4555 // A MixinAppType represents a parsed mixin application clause, e.g. |
4510 // "S<T> with M<U>, N<V>". | 4556 // "S<T> with M<U>, N<V>". |
4511 // MixinAppType objects do not survive finalization, so they do not | 4557 // MixinAppType objects do not survive finalization, so they do not |
(...skipping 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6563 | 6609 |
6564 | 6610 |
6565 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6611 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
6566 intptr_t index) { | 6612 intptr_t index) { |
6567 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6613 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
6568 } | 6614 } |
6569 | 6615 |
6570 } // namespace dart | 6616 } // namespace dart |
6571 | 6617 |
6572 #endif // VM_OBJECT_H_ | 6618 #endif // VM_OBJECT_H_ |
OLD | NEW |