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

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

Issue 9368032: Represent declared type parameters of a class as an array of TypeParameter (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 // Return the signature type of this signature class. 470 // Return the signature type of this signature class.
471 // For example, if this class represents a signature of the form 471 // For example, if this class represents a signature of the form
472 // '<T, R>(T, [b: B, c: C]) => R', then its signature type is a parameterized 472 // '<T, R>(T, [b: B, c: C]) => R', then its signature type is a parameterized
473 // type with this class as the type class and type parameters 'T' and 'R' 473 // type with this class as the type class and type parameters 'T' and 'R'
474 // as its type argument vector. 474 // as its type argument vector.
475 RawType* SignatureType() const; 475 RawType* SignatureType() const;
476 476
477 RawLibrary* library() const { return raw_ptr()->library_; } 477 RawLibrary* library() const { return raw_ptr()->library_; }
478 void set_library(const Library& value) const; 478 void set_library(const Library& value) const;
479 479
480 // The type parameters are specified as an array of Strings. 480 // The type parameters are specified as an array of TypeParameter.
481 // TODO(regis): Store them as an array of TypeParameter with token_index. 481 RawTypeArguments* type_parameters() const {
482 RawArray* type_parameters() const { return raw_ptr()->type_parameters_; } 482 return raw_ptr()->type_parameters_;
483 void set_type_parameters(const Array& value) const; 483 }
484 void set_type_parameters(const TypeArguments& value) const;
484 intptr_t NumTypeParameters() const; 485 intptr_t NumTypeParameters() const;
485 486
486 // Type parameters may optionally extend a Type (Dynamic if no extends). 487 // Type parameter bounds (implicitly Dynamic if not explicitly specified) as
487 // TODO(regis): Should it be Object instead of Dynamic? 488 // an array of AbstractType.
488 RawTypeArguments* type_parameter_extends() const { 489 RawTypeArguments* type_parameter_bounds() const {
489 return raw_ptr()->type_parameter_extends_; 490 return raw_ptr()->type_parameter_bounds_;
490 } 491 }
491 void set_type_parameter_extends(const TypeArguments& value) const; 492 void set_type_parameter_bounds(const TypeArguments& value) const;
492 493
493 // Return a TypeParameter if the type_name is a type parameter of this class. 494 // Return a TypeParameter if the type_name is a type parameter of this class.
494 // Return null otherwise. 495 // Return null otherwise.
495 RawTypeParameter* LookupTypeParameter(const String& type_name, 496 RawTypeParameter* LookupTypeParameter(const String& type_name,
496 intptr_t token_index) const; 497 intptr_t token_index) const;
497 498
498 // The type argument vector is flattened and includes the type arguments of 499 // The type argument vector is flattened and includes the type arguments of
499 // the super class. 500 // the super class.
500 bool HasTypeArguments() const; 501 bool HasTypeArguments() const;
501 intptr_t NumTypeArguments() const; 502 intptr_t NumTypeArguments() const;
(...skipping 24 matching lines...) Expand all
526 // Return the resolved factory class of this interface. 527 // Return the resolved factory class of this interface.
527 RawClass* FactoryClass() const; 528 RawClass* FactoryClass() const;
528 529
529 // Return the unresolved factory class of this interface. 530 // Return the unresolved factory class of this interface.
530 RawUnresolvedClass* UnresolvedFactoryClass() const; 531 RawUnresolvedClass* UnresolvedFactoryClass() const;
531 532
532 // Set the resolved or unresolved factory class of this interface. 533 // Set the resolved or unresolved factory class of this interface.
533 void set_factory_class(const Object& value) const; 534 void set_factory_class(const Object& value) const;
534 535
535 // Interfaces is an array of Types. 536 // Interfaces is an array of Types.
536 // TODO(srdjan): Return TypeArguments instead of Array?
537 RawArray* interfaces() const { return raw_ptr()->interfaces_; } 537 RawArray* interfaces() const { return raw_ptr()->interfaces_; }
538 void set_interfaces(const Array& value) const; 538 void set_interfaces(const Array& value) const;
539 539
540 RawArray* functions_cache() const { return raw_ptr()->functions_cache_; } 540 RawArray* functions_cache() const { return raw_ptr()->functions_cache_; }
541 void set_functions_cache(const Array& value) const; 541 void set_functions_cache(const Array& value) const;
542 542
543 static intptr_t functions_cache_offset() { 543 static intptr_t functions_cache_offset() {
544 return OFFSET_OF(RawClass, functions_cache_); 544 return OFFSET_OF(RawClass, functions_cache_);
545 } 545 }
546 546
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 934
935 // The 'String' interface type. 935 // The 'String' interface type.
936 static RawType* StringInterface(); 936 static RawType* StringInterface();
937 937
938 // The 'Function' interface type. 938 // The 'Function' interface type.
939 static RawType* FunctionInterface(); 939 static RawType* FunctionInterface();
940 940
941 // The 'List' interface type. 941 // The 'List' interface type.
942 static RawType* ListInterface(); 942 static RawType* ListInterface();
943 943
944 // The least specific valid raw type of the given class.
945 // For example, type A<Dynamic> would be returned for class A<T>, and type
946 // B<Dynamic, A<Dynamic>> would be returned for B<U, V extends A>.
947 static RawType* NewRawType(const Class& type_class, intptr_t token_index);
948
949 // The finalized type of the given non-parameterized class. 944 // The finalized type of the given non-parameterized class.
950 static RawType* NewNonParameterizedType(const Class& type_class); 945 static RawType* NewNonParameterizedType(const Class& type_class);
951 946
952 static RawType* New(const Object& clazz, 947 static RawType* New(const Object& clazz,
953 const AbstractTypeArguments& arguments, 948 const AbstractTypeArguments& arguments,
954 intptr_t token_index); 949 intptr_t token_index);
955 950
956 private: 951 private:
957 void set_token_index(intptr_t token_index) const; 952 void set_token_index(intptr_t token_index) const;
958 void set_type_state(int8_t state) const; 953 void set_type_state(int8_t state) const;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 virtual bool IsResolved() const; 1085 virtual bool IsResolved() const;
1091 virtual bool IsInstantiated() const; 1086 virtual bool IsInstantiated() const;
1092 virtual bool IsUninstantiatedIdentity() const; 1087 virtual bool IsUninstantiatedIdentity() const;
1093 1088
1094 protected: 1089 protected:
1095 HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments, Object); 1090 HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments, Object);
1096 friend class Class; 1091 friend class Class;
1097 }; 1092 };
1098 1093
1099 1094
1100 // A TypeArguments is simply an array of Types. 1095 // A TypeArguments is an array of AbstractType.
1101 class TypeArguments : public AbstractTypeArguments { 1096 class TypeArguments : public AbstractTypeArguments {
1102 public: 1097 public:
1103 virtual intptr_t Length() const; 1098 virtual intptr_t Length() const;
1104 virtual RawAbstractType* TypeAt(intptr_t index) const; 1099 virtual RawAbstractType* TypeAt(intptr_t index) const;
1105 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; 1100 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const;
1106 virtual bool IsResolved() const; 1101 virtual bool IsResolved() const;
1107 virtual bool IsInstantiated() const; 1102 virtual bool IsInstantiated() const;
1108 virtual bool IsUninstantiatedIdentity() const; 1103 virtual bool IsUninstantiatedIdentity() const;
1109 // Canonicalize only if instantiated, otherwise returns 'this'. 1104 // Canonicalize only if instantiated, otherwise returns 'this'.
1110 virtual RawAbstractTypeArguments* Canonicalize() const; 1105 virtual RawAbstractTypeArguments* Canonicalize() const;
(...skipping 2537 matching lines...) Expand 10 before | Expand all | Expand 10 after
3648 } 3643 }
3649 3644
3650 3645
3651 void Context::SetAt(intptr_t index, const Instance& value) const { 3646 void Context::SetAt(intptr_t index, const Instance& value) const {
3652 StorePointer(InstanceAddr(index), value.raw()); 3647 StorePointer(InstanceAddr(index), value.raw());
3653 } 3648 }
3654 3649
3655 } // namespace dart 3650 } // namespace dart
3656 3651
3657 #endif // VM_OBJECT_H_ 3652 #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