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

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

Issue 103913005: Introduce class TypeRef in the VM to fully support recursive types. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 4150 matching lines...) Expand 10 before | Expand all | Expand 10 after
4161 virtual bool IsMalformed() const; 4161 virtual bool IsMalformed() const;
4162 virtual bool IsMalbounded() const; 4162 virtual bool IsMalbounded() const;
4163 virtual bool IsMalformedOrMalbounded() const; 4163 virtual bool IsMalformedOrMalbounded() const;
4164 virtual RawLanguageError* error() const { return raw_ptr()->error_; } 4164 virtual RawLanguageError* error() const { return raw_ptr()->error_; }
4165 virtual void set_error(const LanguageError& value) const; 4165 virtual void set_error(const LanguageError& value) const;
4166 virtual bool IsResolved() const; // Class and all arguments classes resolved. 4166 virtual bool IsResolved() const; // Class and all arguments classes resolved.
4167 virtual bool HasResolvedTypeClass() const; // Own type class resolved. 4167 virtual bool HasResolvedTypeClass() const; // Own type class resolved.
4168 virtual RawClass* type_class() const; 4168 virtual RawClass* type_class() const;
4169 void set_type_class(const Object& value) const; 4169 void set_type_class(const Object& value) const;
4170 virtual RawUnresolvedClass* unresolved_class() const; 4170 virtual RawUnresolvedClass* unresolved_class() const;
4171 RawString* TypeClassName() const;
4172 virtual RawAbstractTypeArguments* arguments() const; 4171 virtual RawAbstractTypeArguments* arguments() const;
4173 void set_arguments(const AbstractTypeArguments& value) const; 4172 void set_arguments(const AbstractTypeArguments& value) const;
4174 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } 4173 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; }
4175 virtual bool IsInstantiated() const; 4174 virtual bool IsInstantiated() const;
4176 virtual bool Equals(const Instance& other) const; 4175 virtual bool Equals(const Instance& other) const;
4177 virtual RawAbstractType* InstantiateFrom( 4176 virtual RawAbstractType* InstantiateFrom(
4178 const AbstractTypeArguments& instantiator_type_arguments, 4177 const AbstractTypeArguments& instantiator_type_arguments,
4179 Error* malformed_error) const; 4178 Error* malformed_error) const;
4180 virtual RawAbstractType* CloneUnfinalized() const; 4179 virtual RawAbstractType* CloneUnfinalized() const;
4181 virtual RawAbstractType* Canonicalize() const; 4180 virtual RawAbstractType* Canonicalize() const;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
4243 void set_token_pos(intptr_t token_pos) const; 4242 void set_token_pos(intptr_t token_pos) const;
4244 void set_type_state(int8_t state) const; 4243 void set_type_state(int8_t state) const;
4245 4244
4246 static RawType* New(Heap::Space space = Heap::kOld); 4245 static RawType* New(Heap::Space space = Heap::kOld);
4247 4246
4248 FINAL_HEAP_OBJECT_IMPLEMENTATION(Type, AbstractType); 4247 FINAL_HEAP_OBJECT_IMPLEMENTATION(Type, AbstractType);
4249 friend class Class; 4248 friend class Class;
4250 }; 4249 };
4251 4250
4252 4251
4252 // A TypeRef is used to break cycles in the representation of recursive types.
4253 // Its only field is the recursive AbstractType it refers to.
4254 // Note that the cycle always involves type arguments.
4255 class TypeRef : public AbstractType {
4256 public:
4257 virtual bool IsFinalized() const {
4258 return AbstractType::Handle(type()).IsFinalized();
4259 }
4260 virtual bool IsBeingFinalized() const {
4261 return AbstractType::Handle(type()).IsBeingFinalized();
4262 }
4263 virtual bool IsMalformed() const {
4264 return AbstractType::Handle(type()).IsMalformed();
4265 }
4266 virtual bool IsMalbounded() const {
4267 return AbstractType::Handle(type()).IsMalbounded();
4268 }
4269 virtual bool IsMalformedOrMalbounded() const {
4270 return AbstractType::Handle(type()).IsMalformedOrMalbounded();
4271 }
4272 virtual bool IsResolved() const { return true; }
4273 virtual bool HasResolvedTypeClass() const { return true; }
4274 RawAbstractType* type() const { return raw_ptr()->type_; }
4275 void set_type(const AbstractType& value) const;
4276 virtual RawClass* type_class() const {
4277 return AbstractType::Handle(type()).type_class();
4278 }
4279 virtual RawAbstractTypeArguments* arguments() const {
4280 return AbstractType::Handle(type()).arguments();
4281 }
4282 virtual intptr_t token_pos() const {
4283 return AbstractType::Handle(type()).token_pos();
4284 }
4285 virtual bool IsInstantiated() const;
4286 virtual bool Equals(const Instance& other) const;
4287 virtual RawAbstractType* InstantiateFrom(
4288 const AbstractTypeArguments& instantiator_type_arguments,
4289 Error* bound_error) const;
4290 virtual RawAbstractType* Canonicalize() const;
4291
4292 virtual intptr_t Hash() const;
4293
4294 static intptr_t InstanceSize() {
4295 return RoundedAllocationSize(sizeof(RawTypeRef));
4296 }
4297
4298 static RawTypeRef* New(const AbstractType& type);
4299
4300 private:
4301 bool is_being_checked() const {
4302 return raw_ptr()->is_being_checked_;
4303 }
4304 void set_is_being_checked(bool value) const;
4305
4306 static RawTypeRef* New();
4307
4308 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeRef, AbstractType);
4309 friend class Class;
4310 };
4311
4312
4253 // A TypeParameter represents a type parameter of a parameterized class. 4313 // A TypeParameter represents a type parameter of a parameterized class.
4254 // It specifies its index (and its name for debugging purposes), as well as its 4314 // It specifies its index (and its name for debugging purposes), as well as its
4255 // upper bound. 4315 // upper bound.
4256 // For example, the type parameter 'V' is specified as index 1 in the context of 4316 // For example, the type parameter 'V' is specified as index 1 in the context of
4257 // the class HashMap<K, V>. At compile time, the TypeParameter is not 4317 // the class HashMap<K, V>. At compile time, the TypeParameter is not
4258 // instantiated yet, i.e. it is only a place holder. 4318 // instantiated yet, i.e. it is only a place holder.
4259 // Upon finalization, the TypeParameter index is changed to reflect its position 4319 // Upon finalization, the TypeParameter index is changed to reflect its position
4260 // as type argument (rather than type parameter) of the parameterized class. 4320 // as type argument (rather than type parameter) of the parameterized class.
4261 // If the type parameter is declared without an extends clause, its bound is set 4321 // If the type parameter is declared without an extends clause, its bound is set
4262 // to the ObjectType. 4322 // to the ObjectType.
(...skipping 2190 matching lines...) Expand 10 before | Expand all | Expand 10 after
6453 6513
6454 6514
6455 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 6515 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6456 intptr_t index) { 6516 intptr_t index) {
6457 return array.At((index * kEntryLength) + kTargetFunctionIndex); 6517 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6458 } 6518 }
6459 6519
6460 } // namespace dart 6520 } // namespace dart
6461 6521
6462 #endif // VM_OBJECT_H_ 6522 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698