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 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1009 | 1009 |
1010 // The type argument vector is flattened and includes the type arguments of | 1010 // The type argument vector is flattened and includes the type arguments of |
1011 // the super class. | 1011 // the super class. |
1012 intptr_t NumTypeArguments() const; | 1012 intptr_t NumTypeArguments() const; |
1013 | 1013 |
1014 // Return the number of type arguments that are specific to this class, i.e. | 1014 // Return the number of type arguments that are specific to this class, i.e. |
1015 // not overlapping with the type arguments of the super class of this class. | 1015 // not overlapping with the type arguments of the super class of this class. |
1016 intptr_t NumOwnTypeArguments() const; | 1016 intptr_t NumOwnTypeArguments() const; |
1017 | 1017 |
1018 // Return true if this class declares type parameters. | 1018 // Return true if this class declares type parameters. |
1019 bool IsGeneric() const; | 1019 bool IsGeneric() const { return NumTypeParameters(Thread::Current()) > 0; } |
1020 | 1020 |
1021 // If this class is parameterized, each instance has a type_arguments field. | 1021 // If this class is parameterized, each instance has a type_arguments field. |
1022 static const intptr_t kNoTypeArguments = -1; | 1022 static const intptr_t kNoTypeArguments = -1; |
1023 intptr_t type_arguments_field_offset() const { | 1023 intptr_t type_arguments_field_offset() const { |
1024 ASSERT(is_type_finalized() || is_prefinalized()); | 1024 ASSERT(is_type_finalized() || is_prefinalized()); |
1025 if (raw_ptr()->type_arguments_field_offset_in_words_ == kNoTypeArguments) { | 1025 if (raw_ptr()->type_arguments_field_offset_in_words_ == kNoTypeArguments) { |
1026 return kNoTypeArguments; | 1026 return kNoTypeArguments; |
1027 } | 1027 } |
1028 return raw_ptr()->type_arguments_field_offset_in_words_ * kWordSize; | 1028 return raw_ptr()->type_arguments_field_offset_in_words_ * kWordSize; |
1029 } | 1029 } |
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2289 RawArray* parameter_names() const { return raw_ptr()->parameter_names_; } | 2289 RawArray* parameter_names() const { return raw_ptr()->parameter_names_; } |
2290 void set_parameter_names(const Array& value) const; | 2290 void set_parameter_names(const Array& value) const; |
2291 | 2291 |
2292 // The type parameters (and their bounds) are specified as an array of | 2292 // The type parameters (and their bounds) are specified as an array of |
2293 // TypeParameter. | 2293 // TypeParameter. |
2294 RawTypeArguments* type_parameters() const { | 2294 RawTypeArguments* type_parameters() const { |
2295 return raw_ptr()->type_parameters_; | 2295 return raw_ptr()->type_parameters_; |
2296 } | 2296 } |
2297 void set_type_parameters(const TypeArguments& value) const; | 2297 void set_type_parameters(const TypeArguments& value) const; |
2298 intptr_t NumTypeParameters(Thread* thread) const; | 2298 intptr_t NumTypeParameters(Thread* thread) const; |
2299 intptr_t NumTypeParameters() const { | |
2300 return NumTypeParameters(Thread::Current()); | |
2301 } | |
2302 | 2299 |
2303 // Return a TypeParameter if the type_name is a type parameter of this | 2300 // Return a TypeParameter if the type_name is a type parameter of this |
2304 // function or of one of its parent functions. | 2301 // function or of one of its parent functions. |
2305 // Unless NULL, adjust function_level accordingly (in and out parameter). | 2302 // Unless NULL, adjust function_level accordingly (in and out parameter). |
2306 // Return null otherwise. | 2303 // Return null otherwise. |
2307 RawTypeParameter* LookupTypeParameter(const String& type_name, | 2304 RawTypeParameter* LookupTypeParameter(const String& type_name, |
2308 intptr_t* function_level) const; | 2305 intptr_t* function_level) const; |
2309 | 2306 |
2310 // Return true if this function declares type parameters. | 2307 // Return true if this function declares type parameters. |
2311 bool IsGeneric() const { return NumTypeParameters() > 0; } | 2308 bool IsGeneric() const { return NumTypeParameters(Thread::Current()) > 0; } |
2312 | 2309 |
2313 // Not thread-safe; must be called in the main thread. | 2310 // Not thread-safe; must be called in the main thread. |
2314 // Sets function's code and code's function. | 2311 // Sets function's code and code's function. |
2315 void InstallOptimizedCode(const Code& code, bool is_osr) const; | 2312 void InstallOptimizedCode(const Code& code, bool is_osr) const; |
2316 void AttachCode(const Code& value) const; | 2313 void AttachCode(const Code& value) const; |
2317 void SetInstructions(const Code& value) const; | 2314 void SetInstructions(const Code& value) const; |
2318 void ClearCode() const; | 2315 void ClearCode() const; |
2319 | 2316 |
2320 // Disables optimized code and switches to unoptimized code. | 2317 // Disables optimized code and switches to unoptimized code. |
2321 void SwitchToUnoptimizedCode() const; | 2318 void SwitchToUnoptimizedCode() const; |
(...skipping 3810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6132 } | 6129 } |
6133 bool IsClassTypeParameter() const { | 6130 bool IsClassTypeParameter() const { |
6134 return parameterized_class_id() != kIllegalCid; | 6131 return parameterized_class_id() != kIllegalCid; |
6135 } | 6132 } |
6136 bool IsFunctionTypeParameter() const { | 6133 bool IsFunctionTypeParameter() const { |
6137 return parameterized_function() != Function::null(); | 6134 return parameterized_function() != Function::null(); |
6138 } | 6135 } |
6139 RawString* name() const { return raw_ptr()->name_; } | 6136 RawString* name() const { return raw_ptr()->name_; } |
6140 intptr_t index() const { return raw_ptr()->index_; } | 6137 intptr_t index() const { return raw_ptr()->index_; } |
6141 void set_index(intptr_t value) const; | 6138 void set_index(intptr_t value) const; |
| 6139 intptr_t parent_level() const { return raw_ptr()->parent_level_; } |
6142 RawAbstractType* bound() const { return raw_ptr()->bound_; } | 6140 RawAbstractType* bound() const { return raw_ptr()->bound_; } |
6143 void set_bound(const AbstractType& value) const; | 6141 void set_bound(const AbstractType& value) const; |
6144 // Returns true if bounded_type is below upper_bound, otherwise return false | 6142 // Returns true if bounded_type is below upper_bound, otherwise return false |
6145 // and set bound_error if both bounded_type and upper_bound are instantiated. | 6143 // and set bound_error if both bounded_type and upper_bound are instantiated. |
6146 // If one or both are not instantiated, returning false only means that the | 6144 // If one or both are not instantiated, returning false only means that the |
6147 // bound cannot be checked yet and this is not an error. | 6145 // bound cannot be checked yet and this is not an error. |
6148 bool CheckBound(const AbstractType& bounded_type, | 6146 bool CheckBound(const AbstractType& bounded_type, |
6149 const AbstractType& upper_bound, | 6147 const AbstractType& upper_bound, |
6150 Error* bound_error, | 6148 Error* bound_error, |
6151 TrailPtr bound_trail, | 6149 TrailPtr bound_trail, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6191 TokenPosition token_pos); | 6189 TokenPosition token_pos); |
6192 | 6190 |
6193 private: | 6191 private: |
6194 intptr_t ComputeHash() const; | 6192 intptr_t ComputeHash() const; |
6195 void SetHash(intptr_t value) const; | 6193 void SetHash(intptr_t value) const; |
6196 | 6194 |
6197 void set_parameterized_class(const Class& value) const; | 6195 void set_parameterized_class(const Class& value) const; |
6198 void set_parameterized_function(const Function& value) const; | 6196 void set_parameterized_function(const Function& value) const; |
6199 void set_name(const String& value) const; | 6197 void set_name(const String& value) const; |
6200 void set_token_pos(TokenPosition token_pos) const; | 6198 void set_token_pos(TokenPosition token_pos) const; |
| 6199 void set_parent_level(uint8_t value) const; |
6201 void set_type_state(int8_t state) const; | 6200 void set_type_state(int8_t state) const; |
6202 | 6201 |
6203 static RawTypeParameter* New(); | 6202 static RawTypeParameter* New(); |
6204 | 6203 |
6205 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeParameter, AbstractType); | 6204 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeParameter, AbstractType); |
6206 friend class Class; | 6205 friend class Class; |
6207 }; | 6206 }; |
6208 | 6207 |
6209 | 6208 |
6210 // A BoundedType represents a type instantiated at compile time from a type | 6209 // A BoundedType represents a type instantiated at compile time from a type |
(...skipping 2771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8982 | 8981 |
8983 inline void TypeArguments::SetHash(intptr_t value) const { | 8982 inline void TypeArguments::SetHash(intptr_t value) const { |
8984 // This is only safe because we create a new Smi, which does not cause | 8983 // This is only safe because we create a new Smi, which does not cause |
8985 // heap allocation. | 8984 // heap allocation. |
8986 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); | 8985 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); |
8987 } | 8986 } |
8988 | 8987 |
8989 } // namespace dart | 8988 } // namespace dart |
8990 | 8989 |
8991 #endif // VM_OBJECT_H_ | 8990 #endif // VM_OBJECT_H_ |
OLD | NEW |