| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/assert.h" | 8 #include "vm/assert.h" |
| 9 #include "vm/dart.h" | 9 #include "vm/dart.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 return exception_handlers_class_; | 238 return exception_handlers_class_; |
| 239 } | 239 } |
| 240 static RawClass* context_class() { return context_class_; } | 240 static RawClass* context_class() { return context_class_; } |
| 241 static RawClass* context_scope_class() { return context_scope_class_; } | 241 static RawClass* context_scope_class() { return context_scope_class_; } |
| 242 static RawClass* api_error_class() { return api_error_class_; } | 242 static RawClass* api_error_class() { return api_error_class_; } |
| 243 | 243 |
| 244 static int GetSingletonClassIndex(const RawClass* raw_class); | 244 static int GetSingletonClassIndex(const RawClass* raw_class); |
| 245 static RawClass* GetSingletonClass(int index); | 245 static RawClass* GetSingletonClass(int index); |
| 246 static const char* GetSingletonClassName(int index); | 246 static const char* GetSingletonClassName(int index); |
| 247 | 247 |
| 248 static RawClass* CreateAndRegisterInterface(const char* cname, |
| 249 const Script& script, |
| 250 const Library& lib); |
| 251 static void RegisterClass(const Class& cls, |
| 252 const char* cname, |
| 253 const Script& script, |
| 254 const Library& lib); |
| 255 |
| 248 static void Init(Isolate* isolate); | 256 static void Init(Isolate* isolate); |
| 249 static void InitFromSnapshot(Isolate* isolate); | 257 static void InitFromSnapshot(Isolate* isolate); |
| 250 static void InitOnce(); | 258 static void InitOnce(); |
| 251 | 259 |
| 252 static intptr_t InstanceSize() { | 260 static intptr_t InstanceSize() { |
| 253 return RoundedAllocationSize(sizeof(RawObject)); | 261 return RoundedAllocationSize(sizeof(RawObject)); |
| 254 } | 262 } |
| 255 | 263 |
| 256 static const ObjectKind kInstanceKind = kObject; | 264 static const ObjectKind kInstanceKind = kObject; |
| 257 | 265 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 RawType* SignatureType() const; | 411 RawType* SignatureType() const; |
| 404 | 412 |
| 405 RawLibrary* library() const { return raw_ptr()->library_; } | 413 RawLibrary* library() const { return raw_ptr()->library_; } |
| 406 void set_library(const Library& value) const; | 414 void set_library(const Library& value) const; |
| 407 | 415 |
| 408 // The type parameters are specified as an array of Strings. | 416 // The type parameters are specified as an array of Strings. |
| 409 RawArray* type_parameters() const { return raw_ptr()->type_parameters_; } | 417 RawArray* type_parameters() const { return raw_ptr()->type_parameters_; } |
| 410 void set_type_parameters(const Array& value) const; | 418 void set_type_parameters(const Array& value) const; |
| 411 intptr_t NumTypeParameters() const; | 419 intptr_t NumTypeParameters() const; |
| 412 | 420 |
| 413 // Type parameters may optionally extend a Type (DynamicType if no extends). | 421 // Type parameters may optionally extend a Type (Dynamic if no extends). |
| 422 // TODO(regis): Should it be Object instead of Dynamic? |
| 414 RawTypeArray* type_parameter_extends() const { | 423 RawTypeArray* type_parameter_extends() const { |
| 415 return raw_ptr()->type_parameter_extends_; | 424 return raw_ptr()->type_parameter_extends_; |
| 416 } | 425 } |
| 417 void set_type_parameter_extends(const TypeArray& value) const; | 426 void set_type_parameter_extends(const TypeArray& value) const; |
| 418 | 427 |
| 419 // Return a TypeParameter if the type_name is a type parameter of this class. | 428 // Return a TypeParameter if the type_name is a type parameter of this class. |
| 420 // Return null otherwise. | 429 // Return null otherwise. |
| 421 RawTypeParameter* LookupTypeParameter(const String& type_name) const; | 430 RawTypeParameter* LookupTypeParameter(const String& type_name) const; |
| 422 | 431 |
| 432 // The type argument vector is flattened and includes the type arguments of |
| 433 // the super class. |
| 434 bool HasTypeArguments() const; |
| 435 intptr_t NumTypeArguments() const; |
| 436 |
| 423 // If this class is parameterized, each instance has a type_arguments field. | 437 // If this class is parameterized, each instance has a type_arguments field. |
| 424 intptr_t NumTypeArguments() const; | |
| 425 static const intptr_t kNoTypeArguments = -1; | 438 static const intptr_t kNoTypeArguments = -1; |
| 426 intptr_t type_arguments_instance_field_offset() const { | 439 intptr_t type_arguments_instance_field_offset() const { |
| 427 ASSERT(is_finalized() || is_prefinalized()); | 440 ASSERT(is_finalized() || is_prefinalized()); |
| 428 return raw_ptr()->type_arguments_instance_field_offset_; | 441 return raw_ptr()->type_arguments_instance_field_offset_; |
| 429 } | 442 } |
| 430 void set_type_arguments_instance_field_offset(intptr_t value) const { | 443 void set_type_arguments_instance_field_offset(intptr_t value) const { |
| 431 raw_ptr()->type_arguments_instance_field_offset_ = value; | 444 raw_ptr()->type_arguments_instance_field_offset_ = value; |
| 432 } | 445 } |
| 433 bool HasTypeArguments() const { | |
| 434 if (is_finalized() || is_prefinalized()) { | |
| 435 // More efficient than calling NumTypeArguments(). | |
| 436 return type_arguments_instance_field_offset() != kNoTypeArguments; | |
| 437 } else { | |
| 438 // No need to check NumTypeArguments() if class has type parameters. | |
| 439 return (NumTypeParameters() > 0) || (NumTypeArguments() > 0); | |
| 440 } | |
| 441 } | |
| 442 | 446 |
| 443 // The super type of this class, Object type if not explicitly specified. | 447 // The super type of this class, Object type if not explicitly specified. |
| 444 RawType* super_type() const { return raw_ptr()->super_type_; } | 448 RawType* super_type() const { return raw_ptr()->super_type_; } |
| 445 void set_super_type(const Type& value) const; | 449 void set_super_type(const Type& value) const; |
| 446 | 450 |
| 447 // Asserts that the class of the super type has been resolved. | 451 // Asserts that the class of the super type has been resolved. |
| 448 RawClass* SuperClass() const; | 452 RawClass* SuperClass() const; |
| 449 | 453 |
| 450 // The factory type of this interface, null if not specified. | 454 // The factory type of this interface, null if not specified. |
| 451 RawType* factory_type() const { return raw_ptr()->factory_type_; } | 455 RawType* factory_type() const { return raw_ptr()->factory_type_; } |
| (...skipping 2551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3003 } | 3007 } |
| 3004 | 3008 |
| 3005 | 3009 |
| 3006 void Context::SetAt(intptr_t index, const Instance& value) const { | 3010 void Context::SetAt(intptr_t index, const Instance& value) const { |
| 3007 StorePointer(InstanceAddr(index), value.raw()); | 3011 StorePointer(InstanceAddr(index), value.raw()); |
| 3008 } | 3012 } |
| 3009 | 3013 |
| 3010 } // namespace dart | 3014 } // namespace dart |
| 3011 | 3015 |
| 3012 #endif // VM_OBJECT_H_ | 3016 #endif // VM_OBJECT_H_ |
| OLD | NEW |