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

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

Issue 1815733003: Remove recently introduced FunctionType vm class by merging it into class Type. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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
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 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 // Check if this class represents the 'dynamic' class. 1095 // Check if this class represents the 'dynamic' class.
1096 bool IsDynamicClass() const { return id() == kDynamicCid; } 1096 bool IsDynamicClass() const { return id() == kDynamicCid; }
1097 1097
1098 // Check if this class represents the 'void' class. 1098 // Check if this class represents the 'void' class.
1099 bool IsVoidClass() const { return id() == kVoidCid; } 1099 bool IsVoidClass() const { return id() == kVoidCid; }
1100 1100
1101 // Check if this class represents the 'Object' class. 1101 // Check if this class represents the 'Object' class.
1102 bool IsObjectClass() const { return id() == kInstanceCid; } 1102 bool IsObjectClass() const { return id() == kInstanceCid; }
1103 1103
1104 // Check if this class represents the 'Function' class. 1104 // Check if this class represents the 'Function' class.
1105 bool IsFunctionClass() const; 1105 bool IsDartFunctionClass() const;
1106 1106
1107 // Check if this class represents the 'Closure' class. 1107 // Check if this class represents the 'Closure' class.
1108 bool IsClosureClass() const { return id() == kClosureCid; } 1108 bool IsClosureClass() const { return id() == kClosureCid; }
1109 static bool IsClosureClass(RawClass* cls) { 1109 static bool IsClosureClass(RawClass* cls) {
1110 NoSafepointScope no_safepoint; 1110 NoSafepointScope no_safepoint;
1111 return cls->ptr()->id_ == kClosureCid; 1111 return cls->ptr()->id_ == kClosureCid;
1112 } 1112 }
1113 1113
1114 // Check if this class represents a typedef class. 1114 // Check if this class represents a typedef class.
1115 bool IsTypedefClass() const { 1115 bool IsTypedefClass() const {
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 1507
1508 // Returns canonical type. Thread safe. 1508 // Returns canonical type. Thread safe.
1509 RawAbstractType* LookupOrAddCanonicalType(const AbstractType& type, 1509 RawAbstractType* LookupOrAddCanonicalType(const AbstractType& type,
1510 intptr_t start_index) const; 1510 intptr_t start_index) const;
1511 1511
1512 FINAL_HEAP_OBJECT_IMPLEMENTATION(Class, Object); 1512 FINAL_HEAP_OBJECT_IMPLEMENTATION(Class, Object);
1513 friend class AbstractType; 1513 friend class AbstractType;
1514 friend class Instance; 1514 friend class Instance;
1515 friend class Object; 1515 friend class Object;
1516 friend class Type; 1516 friend class Type;
1517 friend class FunctionType;
1518 friend class Intrinsifier; 1517 friend class Intrinsifier;
1519 friend class Precompiler; 1518 friend class Precompiler;
1520 }; 1519 };
1521 1520
1522 1521
1523 // Unresolved class is used for storing unresolved names which will be resolved 1522 // Unresolved class is used for storing unresolved names which will be resolved
1524 // to a class after all classes have been loaded and finalized. 1523 // to a class after all classes have been loaded and finalized.
1525 class UnresolvedClass : public Object { 1524 class UnresolvedClass : public Object {
1526 public: 1525 public:
1527 RawLibraryPrefix* library_prefix() const { 1526 RawLibraryPrefix* library_prefix() const {
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 } 2139 }
2141 RawString* QualifiedUserVisibleName() const { 2140 RawString* QualifiedUserVisibleName() const {
2142 return QualifiedName(kUserVisibleName); 2141 return QualifiedName(kUserVisibleName);
2143 } 2142 }
2144 virtual RawString* DictionaryName() const { return name(); } 2143 virtual RawString* DictionaryName() const { return name(); }
2145 2144
2146 RawString* GetSource() const; 2145 RawString* GetSource() const;
2147 2146
2148 // Return the type of this function's signature. It may not be canonical yet. 2147 // Return the type of this function's signature. It may not be canonical yet.
2149 // For example, if this function has a signature of the form 2148 // For example, if this function has a signature of the form
2150 // '(T, [b: B, c: C]) => R', where 'T' and 'R' are type parameters of the 2149 // '(T, [B, C]) => R', where 'T' and 'R' are type parameters of the
2151 // owner class of this function, then its signature type is a parameterized 2150 // owner class of this function, then its signature type is a parameterized
2152 // FunctionType with uninstantiated type arguments 'T' and 'R' as elements of 2151 // function type with uninstantiated type arguments 'T' and 'R' as elements of
2153 // its type argument vector. 2152 // its type argument vector.
2154 RawFunctionType* SignatureType() const; 2153 RawType* SignatureType() const;
2155 2154
2156 // Update the signature type (with a canonical version). 2155 // Update the signature type (with a canonical version).
2157 void SetSignatureType(const FunctionType& value) const; 2156 void SetSignatureType(const Type& value) const;
2158 2157
2159 // Build a string of the form 'C<T, R>(T, {b: B, c: C}) => R' representing the 2158 // Build a string of the form 'C<T, R>(T, {B b, C c}) => R' representing the
2160 // internal signature of the given function. In this example, T and R are 2159 // internal signature of the given function. In this example, T and R are
2161 // type parameters of class C, the owner of the function. 2160 // type parameters of class C, the owner of the function.
2162 RawString* Signature() const { 2161 RawString* Signature() const {
2163 const bool instantiate = false; 2162 const bool instantiate = false;
2164 return BuildSignature(instantiate, kInternalName, TypeArguments::Handle()); 2163 return BuildSignature(instantiate, kInternalName, TypeArguments::Handle());
2165 } 2164 }
2166 2165
2167 // Build a string of the form '(T, {b: B, c: C}) => R' representing the 2166 // Build a string of the form '(T, {B b, C c}) => R' representing the
2168 // user visible signature of the given function. In this example, T and R are 2167 // user visible signature of the given function. In this example, T and R are
2169 // type parameters of class C, the owner of the function, also called the 2168 // type parameters of class C, the owner of the function, also called the
2170 // scope class of the function type. 2169 // scope class of the function type.
2171 // Implicit parameters are hidden, as well as the prefix denoting the 2170 // Implicit parameters are hidden, as well as the prefix denoting the
2172 // scope class and its type parameters. 2171 // scope class and its type parameters.
2173 RawString* UserVisibleSignature() const { 2172 RawString* UserVisibleSignature() const {
2174 const bool instantiate = false; 2173 const bool instantiate = false;
2175 return BuildSignature( 2174 return BuildSignature(
2176 instantiate, kUserVisibleName, TypeArguments::Handle()); 2175 instantiate, kUserVisibleName, TypeArguments::Handle());
2177 } 2176 }
2178 2177
2179 // Build a string of the form '(A, {b: B, c: C}) => D' representing the 2178 // Build a string of the form '(A, {B b, C c}) => D' representing the
2180 // signature of the given function, where all generic types (e.g. '<T, R>' in 2179 // signature of the given function, where all generic types (e.g. '<T, R>' in
2181 // 'C<T, R>(T, {b: B, c: C}) => R') are instantiated using the given 2180 // 'C<T, R>(T, {B b, C c}) => R') are instantiated using the given
2182 // instantiator type argument vector of a C instance (e.g. '<A, D>'). 2181 // instantiator type argument vector of a C instance (e.g. '<A, D>').
2183 RawString* InstantiatedSignatureFrom(const TypeArguments& instantiator, 2182 RawString* InstantiatedSignatureFrom(const TypeArguments& instantiator,
2184 NameVisibility name_visibility) const { 2183 NameVisibility name_visibility) const {
2185 const bool instantiate = true; 2184 const bool instantiate = true;
2186 return BuildSignature(instantiate, name_visibility, instantiator); 2185 return BuildSignature(instantiate, name_visibility, instantiator);
2187 } 2186 }
2188 2187
2189 // Returns true if the signature of this function is instantiated, i.e. if it 2188 // Returns true if the signature of this function is instantiated, i.e. if it
2190 // does not involve generic parameter types or generic result type. 2189 // does not involve generic parameter types or generic result type.
2191 bool HasInstantiatedSignature() const; 2190 bool HasInstantiatedSignature() const;
2192 2191
2193 // Build a string of the form 'T, {b: B, c: C} representing the user 2192 // Build a string of the form 'T, {B b, C c}' representing the user
2194 // visible formal parameters of the function. 2193 // visible formal parameters of the function.
2195 RawString* UserVisibleFormalParameters() const; 2194 RawString* UserVisibleFormalParameters() const;
2196 2195
2197 RawClass* Owner() const; 2196 RawClass* Owner() const;
2198 RawClass* origin() const; 2197 RawClass* origin() const;
2199 RawScript* script() const; 2198 RawScript* script() const;
2200 RawObject* RawOwner() const { return raw_ptr()->owner_; } 2199 RawObject* RawOwner() const { return raw_ptr()->owner_; }
2201 2200
2202 RawJSRegExp* regexp() const; 2201 RawJSRegExp* regexp() const;
2203 intptr_t string_specialization_cid() const; 2202 intptr_t string_specialization_cid() const;
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
2861 2860
2862 private: 2861 private:
2863 RawContextScope* context_scope() const { return raw_ptr()->context_scope_; } 2862 RawContextScope* context_scope() const { return raw_ptr()->context_scope_; }
2864 void set_context_scope(const ContextScope& value) const; 2863 void set_context_scope(const ContextScope& value) const;
2865 2864
2866 // Enclosing function of this local function. 2865 // Enclosing function of this local function.
2867 RawFunction* parent_function() const { return raw_ptr()->parent_function_; } 2866 RawFunction* parent_function() const { return raw_ptr()->parent_function_; }
2868 void set_parent_function(const Function& value) const; 2867 void set_parent_function(const Function& value) const;
2869 2868
2870 // Signature type of this closure function. 2869 // Signature type of this closure function.
2871 RawFunctionType* signature_type() const { return raw_ptr()->signature_type_; } 2870 RawType* signature_type() const { return raw_ptr()->signature_type_; }
2872 void set_signature_type(const FunctionType& value) const; 2871 void set_signature_type(const Type& value) const;
2873 2872
2874 RawInstance* implicit_static_closure() const { 2873 RawInstance* implicit_static_closure() const {
2875 return raw_ptr()->closure_; 2874 return raw_ptr()->closure_;
2876 } 2875 }
2877 void set_implicit_static_closure(const Instance& closure) const; 2876 void set_implicit_static_closure(const Instance& closure) const;
2878 2877
2879 static RawClosureData* New(); 2878 static RawClosureData* New();
2880 2879
2881 FINAL_HEAP_OBJECT_IMPLEMENTATION(ClosureData, Object); 2880 FINAL_HEAP_OBJECT_IMPLEMENTATION(ClosureData, Object);
2882 friend class Class; 2881 friend class Class;
(...skipping 2440 matching lines...) Expand 10 before | Expand all | Expand 10 after
5323 virtual bool IsInstantiated(TrailPtr trail = NULL) const; 5322 virtual bool IsInstantiated(TrailPtr trail = NULL) const;
5324 virtual bool CanonicalizeEquals(const Instance& other) const { 5323 virtual bool CanonicalizeEquals(const Instance& other) const {
5325 return Equals(other); 5324 return Equals(other);
5326 } 5325 }
5327 virtual bool Equals(const Instance& other) const { 5326 virtual bool Equals(const Instance& other) const {
5328 return IsEquivalent(other); 5327 return IsEquivalent(other);
5329 } 5328 }
5330 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; 5329 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const;
5331 virtual bool IsRecursive() const; 5330 virtual bool IsRecursive() const;
5332 5331
5332 // Check if this type represents a function type.
5333 virtual bool IsFunctionType() const { return false; }
5334
5333 // Instantiate this type using the given type argument vector. 5335 // Instantiate this type using the given type argument vector.
5334 // Return a new type, or return 'this' if it is already instantiated. 5336 // Return a new type, or return 'this' if it is already instantiated.
5335 // If bound_error is not NULL, it may be set to reflect a bound error. 5337 // If bound_error is not NULL, it may be set to reflect a bound error.
5336 virtual RawAbstractType* InstantiateFrom( 5338 virtual RawAbstractType* InstantiateFrom(
5337 const TypeArguments& instantiator_type_arguments, 5339 const TypeArguments& instantiator_type_arguments,
5338 Error* bound_error, 5340 Error* bound_error,
5339 TrailPtr instantiation_trail, 5341 TrailPtr instantiation_trail,
5340 TrailPtr bound_trail, 5342 TrailPtr bound_trail,
5341 Heap::Space space) const; 5343 Heap::Space space) const;
5342 5344
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
5398 virtual RawString* EnumerateURIs() const; 5400 virtual RawString* EnumerateURIs() const;
5399 5401
5400 virtual intptr_t Hash() const; 5402 virtual intptr_t Hash() const;
5401 5403
5402 // The name of this type's class, i.e. without the type argument names of this 5404 // The name of this type's class, i.e. without the type argument names of this
5403 // type. 5405 // type.
5404 RawString* ClassName() const; 5406 RawString* ClassName() const;
5405 5407
5406 // Check if this type represents the 'dynamic' type. 5408 // Check if this type represents the 'dynamic' type.
5407 bool IsDynamicType() const { 5409 bool IsDynamicType() const {
5408 return HasResolvedTypeClass() && (type_class() == Object::dynamic_class()); 5410 return !IsFunctionType() &&
5411 HasResolvedTypeClass() &&
5412 (type_class() == Object::dynamic_class());
5409 } 5413 }
5410 5414
5411 // Check if this type represents the 'Null' type. 5415 // Check if this type represents the 'Null' type.
5412 bool IsNullType() const; 5416 bool IsNullType() const;
5413 5417
5414 // Check if this type represents the 'void' type. 5418 // Check if this type represents the 'void' type.
5415 bool IsVoidType() const { 5419 bool IsVoidType() const {
5416 return HasResolvedTypeClass() && (type_class() == Object::void_class()); 5420 return !IsFunctionType() &&
5421 HasResolvedTypeClass() &&
5422 (type_class() == Object::void_class());
5417 } 5423 }
5418 5424
5419 bool IsObjectType() const { 5425 bool IsObjectType() const {
5420 return HasResolvedTypeClass() && 5426 return !IsFunctionType() &&
5421 Class::Handle(type_class()).IsObjectClass(); 5427 HasResolvedTypeClass() &&
5428 Class::Handle(type_class()).IsObjectClass();
5422 } 5429 }
5423 5430
5424 // Check if this type represents the 'bool' type. 5431 // Check if this type represents the 'bool' type.
5425 bool IsBoolType() const; 5432 bool IsBoolType() const;
5426 5433
5427 // Check if this type represents the 'int' type. 5434 // Check if this type represents the 'int' type.
5428 bool IsIntType() const; 5435 bool IsIntType() const;
5429 5436
5430 // Check if this type represents the 'double' type. 5437 // Check if this type represents the 'double' type.
5431 bool IsDoubleType() const; 5438 bool IsDoubleType() const;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
5499 public: 5506 public:
5500 static intptr_t type_class_offset() { 5507 static intptr_t type_class_offset() {
5501 return OFFSET_OF(RawType, type_class_); 5508 return OFFSET_OF(RawType, type_class_);
5502 } 5509 }
5503 virtual bool IsFinalized() const { 5510 virtual bool IsFinalized() const {
5504 return 5511 return
5505 (raw_ptr()->type_state_ == RawType::kFinalizedInstantiated) || 5512 (raw_ptr()->type_state_ == RawType::kFinalizedInstantiated) ||
5506 (raw_ptr()->type_state_ == RawType::kFinalizedUninstantiated); 5513 (raw_ptr()->type_state_ == RawType::kFinalizedUninstantiated);
5507 } 5514 }
5508 virtual void SetIsFinalized() const; 5515 virtual void SetIsFinalized() const;
5516 void ResetIsFinalized() const; // Ignore current state and set again.
5509 virtual bool IsBeingFinalized() const { 5517 virtual bool IsBeingFinalized() const {
5510 return raw_ptr()->type_state_ == RawType::kBeingFinalized; 5518 return raw_ptr()->type_state_ == RawType::kBeingFinalized;
5511 } 5519 }
5512 virtual void SetIsBeingFinalized() const; 5520 virtual void SetIsBeingFinalized() const;
5513 virtual bool IsMalformed() const; 5521 virtual bool IsMalformed() const;
5514 virtual bool IsMalbounded() const; 5522 virtual bool IsMalbounded() const;
5515 virtual bool IsMalformedOrMalbounded() const; 5523 virtual bool IsMalformedOrMalbounded() const;
5516 virtual RawLanguageError* error() const { return raw_ptr()->error_; } 5524 virtual RawLanguageError* error() const;
5517 virtual void set_error(const LanguageError& value) const; 5525 virtual void set_error(const LanguageError& value) const;
5518 virtual bool IsResolved() const { 5526 virtual bool IsResolved() const {
5519 return raw_ptr()->type_state_ >= RawType::kResolved; 5527 return raw_ptr()->type_state_ >= RawType::kResolved;
5520 } 5528 }
5521 virtual void SetIsResolved() const; 5529 virtual void SetIsResolved() const;
5522 virtual bool HasResolvedTypeClass() const; // Own type class resolved. 5530 virtual bool HasResolvedTypeClass() const; // Own type class resolved.
5523 virtual RawClass* type_class() const; 5531 virtual RawClass* type_class() const;
5524 void set_type_class(const Object& value) const; 5532 void set_type_class(const Object& value) const;
5525 virtual RawUnresolvedClass* unresolved_class() const; 5533 virtual RawUnresolvedClass* unresolved_class() const;
5526 virtual RawTypeArguments* arguments() const { return raw_ptr()->arguments_; } 5534 virtual RawTypeArguments* arguments() const { return raw_ptr()->arguments_; }
5527 virtual void set_arguments(const TypeArguments& value) const; 5535 virtual void set_arguments(const TypeArguments& value) const;
5528 virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; } 5536 virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; }
5529 virtual bool IsInstantiated(TrailPtr trail = NULL) const; 5537 virtual bool IsInstantiated(TrailPtr trail = NULL) const;
5530 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; 5538 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const;
5531 virtual bool IsRecursive() const; 5539 virtual bool IsRecursive() const;
5540 // If signature is not null, this type represents a function type.
5541 RawFunction* signature() const;
5542 void set_signature(const Function& value) const;
5543 virtual bool IsFunctionType() const {
5544 return signature() != Function::null();
5545 }
5532 virtual RawAbstractType* InstantiateFrom( 5546 virtual RawAbstractType* InstantiateFrom(
5533 const TypeArguments& instantiator_type_arguments, 5547 const TypeArguments& instantiator_type_arguments,
5534 Error* bound_error, 5548 Error* bound_error,
5535 TrailPtr instantiation_trail, 5549 TrailPtr instantiation_trail,
5536 TrailPtr bound_trail, 5550 TrailPtr bound_trail,
5537 Heap::Space space) const; 5551 Heap::Space space) const;
5538 virtual RawAbstractType* CloneUnfinalized() const; 5552 virtual RawAbstractType* CloneUnfinalized() const;
5539 virtual RawAbstractType* CloneUninstantiated( 5553 virtual RawAbstractType* CloneUninstantiated(
5540 const Class& new_owner, 5554 const Class& new_owner,
5541 TrailPtr trail = NULL) const; 5555 TrailPtr trail = NULL) const;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
5587 // The 'num' type. 5601 // The 'num' type.
5588 static RawType* Number(); 5602 static RawType* Number();
5589 5603
5590 // The 'String' type. 5604 // The 'String' type.
5591 static RawType* StringType(); 5605 static RawType* StringType();
5592 5606
5593 // The 'Array' type. 5607 // The 'Array' type.
5594 static RawType* ArrayType(); 5608 static RawType* ArrayType();
5595 5609
5596 // The 'Function' type. 5610 // The 'Function' type.
5597 static RawType* Function(); 5611 static RawType* DartFunctionType();
5598 5612
5599 // The finalized type of the given non-parameterized class. 5613 // The finalized type of the given non-parameterized class.
5600 static RawType* NewNonParameterizedType(const Class& type_class); 5614 static RawType* NewNonParameterizedType(const Class& type_class);
5601 5615
5602 static RawType* New(const Object& clazz, 5616 static RawType* New(const Object& clazz,
5603 const TypeArguments& arguments, 5617 const TypeArguments& arguments,
5604 TokenPosition token_pos, 5618 TokenPosition token_pos,
5605 Heap::Space space = Heap::kOld); 5619 Heap::Space space = Heap::kOld);
5606 5620
5607 private: 5621 private:
5608 void set_token_pos(TokenPosition token_pos) const; 5622 void set_token_pos(TokenPosition token_pos) const;
5609 void set_type_state(int8_t state) const; 5623 void set_type_state(int8_t state) const;
5610 5624
5611 static RawType* New(Heap::Space space = Heap::kOld); 5625 static RawType* New(Heap::Space space = Heap::kOld);
5612 5626
5613 FINAL_HEAP_OBJECT_IMPLEMENTATION(Type, AbstractType); 5627 FINAL_HEAP_OBJECT_IMPLEMENTATION(Type, AbstractType);
5614 friend class Class; 5628 friend class Class;
5615 friend class TypeArguments; 5629 friend class TypeArguments;
5616 }; 5630 };
5617 5631
5618 5632
5619 // TODO(regis): FunctionType is very similar to Type. Instead of a separate
5620 // class FunctionType, we could consider an object of class Type as representing
5621 // a function type if it has a non-null function (signature) field.
5622 // In order to save space, we could reuse the error_ field? A malformed or
5623 // malbounded function type would lose its function reference, but the error
5624 // string would contain relevant info.
5625
5626 // A FunctionType describes the signature of a function, i.e. the result type
5627 // and formal parameter types of the function, as well as the names of optional
5628 // named formal parameters.
5629 // If these types refer to type parameters of a class in scope, the function
5630 // type is generic. A generic function type may be instantiated by a type
5631 // argument vector.
5632 // Therefore, a FunctionType consists of a scope class, a type argument vector,
5633 // and a signature.
5634 // The scope class is either a generic class (or generic typedef) declaring the
5635 // type parameters referred to by the signature, or class _Closure in the
5636 // non-generic case (including the non-generic typedef case).
5637 // The type arguments specify an instantiation of the generic signature (null in
5638 // the non-generic case).
5639 // The signature is a reference to an actual closure function (kClosureFunction)
5640 // or to a signature function (kSignatureFunction).
5641 // Since typedefs cannot refer to themselves, directly or indirectly, a
5642 // FunctionType cannot be recursive. Only individual formal parameter types can.
5643 class FunctionType : public AbstractType {
5644 public:
5645 virtual bool IsFinalized() const {
5646 return
5647 (raw_ptr()->type_state_ == RawFunctionType::kFinalizedInstantiated) ||
5648 (raw_ptr()->type_state_ == RawFunctionType::kFinalizedUninstantiated);
5649 }
5650 virtual void SetIsFinalized() const;
5651 void ResetIsFinalized() const; // Ignore current state and set again.
5652 virtual bool IsBeingFinalized() const {
5653 return raw_ptr()->type_state_ == RawFunctionType::kBeingFinalized;
5654 }
5655 virtual void SetIsBeingFinalized() const;
5656 virtual bool IsMalformed() const;
5657 virtual bool IsMalbounded() const;
5658 virtual bool IsMalformedOrMalbounded() const;
5659 virtual RawLanguageError* error() const { return raw_ptr()->error_; }
5660 virtual void set_error(const LanguageError& value) const;
5661 virtual bool IsResolved() const {
5662 return raw_ptr()->type_state_ >= RawFunctionType::kResolved;
5663 }
5664 virtual void SetIsResolved() const;
5665 // The scope class of a FunctionType is always resolved. It has no actual
5666 // type class. Returning false is important for the type testers to work, e.g.
5667 // IsDynamicType(), IsBoolType(), etc...
5668 virtual bool HasResolvedTypeClass() const { return false; }
5669 // Return scope_class from virtual type_class() to factorize finalization
5670 // with Type, also a parameterized type.
5671 virtual RawClass* type_class() const { return scope_class(); }
5672 RawClass* scope_class() const { return raw_ptr()->scope_class_; }
5673 void set_scope_class(const Class& value) const;
5674 virtual RawTypeArguments* arguments() const { return raw_ptr()->arguments_; }
5675 virtual void set_arguments(const TypeArguments& value) const;
5676 RawFunction* signature() const { return raw_ptr()->signature_; }
5677 virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; }
5678 virtual bool IsInstantiated(TrailPtr trail = NULL) const;
5679 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const;
5680 virtual bool IsRecursive() const;
5681 virtual RawAbstractType* InstantiateFrom(
5682 const TypeArguments& instantiator_type_arguments,
5683 Error* malformed_error,
5684 TrailPtr instantiation_trail,
5685 TrailPtr bound_trail,
5686 Heap::Space space) const;
5687 virtual RawAbstractType* CloneUnfinalized() const;
5688 virtual RawAbstractType* CloneUninstantiated(
5689 const Class& new_owner,
5690 TrailPtr trail = NULL) const;
5691 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const;
5692 virtual RawString* EnumerateURIs() const;
5693
5694 virtual intptr_t Hash() const;
5695
5696 static intptr_t InstanceSize() {
5697 return RoundedAllocationSize(sizeof(RawFunctionType));
5698 }
5699
5700 static RawFunctionType* New(const Class& scope_class,
5701 const TypeArguments& arguments,
5702 const Function& signature,
5703 TokenPosition token_pos,
5704 Heap::Space space = Heap::kOld);
5705
5706 private:
5707 void set_signature(const Function& value) const;
5708 void set_token_pos(TokenPosition token_pos) const;
5709 void set_type_state(int8_t state) const;
5710
5711 static RawFunctionType* New(Heap::Space space = Heap::kOld);
5712
5713 FINAL_HEAP_OBJECT_IMPLEMENTATION(FunctionType, AbstractType);
5714 friend class Class;
5715 friend class TypeArguments;
5716 };
5717
5718
5719 // A TypeRef is used to break cycles in the representation of recursive types. 5633 // A TypeRef is used to break cycles in the representation of recursive types.
5720 // Its only field is the recursive AbstractType it refers to. 5634 // Its only field is the recursive AbstractType it refers to.
5721 // Note that the cycle always involves type arguments. 5635 // Note that the cycle always involves type arguments.
5722 class TypeRef : public AbstractType { 5636 class TypeRef : public AbstractType {
5723 public: 5637 public:
5724 virtual bool IsFinalized() const { 5638 virtual bool IsFinalized() const {
5725 return AbstractType::Handle(type()).IsFinalized(); 5639 return AbstractType::Handle(type()).IsFinalized();
5726 } 5640 }
5727 virtual bool IsBeingFinalized() const { 5641 virtual bool IsBeingFinalized() const {
5728 return AbstractType::Handle(type()).IsBeingFinalized(); 5642 return AbstractType::Handle(type()).IsBeingFinalized();
5729 } 5643 }
5730 virtual bool IsMalformed() const { 5644 virtual bool IsMalformed() const {
5731 return AbstractType::Handle(type()).IsMalformed(); 5645 return AbstractType::Handle(type()).IsMalformed();
5732 } 5646 }
5733 virtual bool IsMalbounded() const { 5647 virtual bool IsMalbounded() const {
5734 return AbstractType::Handle(type()).IsMalbounded(); 5648 return AbstractType::Handle(type()).IsMalbounded();
5735 } 5649 }
5736 virtual bool IsMalformedOrMalbounded() const { 5650 virtual bool IsMalformedOrMalbounded() const {
5737 return AbstractType::Handle(type()).IsMalformedOrMalbounded(); 5651 return AbstractType::Handle(type()).IsMalformedOrMalbounded();
5738 } 5652 }
5739 virtual bool IsResolved() const { return true; } 5653 virtual bool IsResolved() const { return true; }
5740 virtual bool HasResolvedTypeClass() const { 5654 virtual bool HasResolvedTypeClass() const {
5741 // Returns false if the ref type is a function type.
5742 return AbstractType::Handle(type()).HasResolvedTypeClass(); 5655 return AbstractType::Handle(type()).HasResolvedTypeClass();
5743 } 5656 }
5744 RawAbstractType* type() const { return raw_ptr()->type_; } 5657 RawAbstractType* type() const { return raw_ptr()->type_; }
5745 void set_type(const AbstractType& value) const; 5658 void set_type(const AbstractType& value) const;
5746 virtual RawClass* type_class() const { 5659 virtual RawClass* type_class() const {
5747 return AbstractType::Handle(type()).type_class(); 5660 return AbstractType::Handle(type()).type_class();
5748 } 5661 }
5749 virtual RawTypeArguments* arguments() const { 5662 virtual RawTypeArguments* arguments() const {
5750 return AbstractType::Handle(type()).arguments(); 5663 return AbstractType::Handle(type()).arguments();
5751 } 5664 }
(...skipping 2753 matching lines...) Expand 10 before | Expand all | Expand 10 after
8505 8418
8506 8419
8507 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 8420 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
8508 intptr_t index) { 8421 intptr_t index) {
8509 return array.At((index * kEntryLength) + kTargetFunctionIndex); 8422 return array.At((index * kEntryLength) + kTargetFunctionIndex);
8510 } 8423 }
8511 8424
8512 } // namespace dart 8425 } // namespace dart
8513 8426
8514 #endif // VM_OBJECT_H_ 8427 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698