| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 class Object { | 112 class Object { |
| 113 public: | 113 public: |
| 114 // Index for Singleton internal VM classes, | 114 // Index for Singleton internal VM classes, |
| 115 // this index is used in snapshots to refer to these classes directly. | 115 // this index is used in snapshots to refer to these classes directly. |
| 116 enum { | 116 enum { |
| 117 kNullObject = 0, | 117 kNullObject = 0, |
| 118 kSentinelObject, | 118 kSentinelObject, |
| 119 kClassClass, | 119 kClassClass, |
| 120 kNullClass, | 120 kNullClass, |
| 121 kVarClass, | 121 kDynamicClass, |
| 122 kVoidClass, | 122 kVoidClass, |
| 123 kUnresolvedClassClass, | 123 kUnresolvedClassClass, |
| 124 kParameterizedTypeClass, | 124 kParameterizedTypeClass, |
| 125 kTypeParameterClass, | 125 kTypeParameterClass, |
| 126 kInstantiatedTypeClass, | 126 kInstantiatedTypeClass, |
| 127 kTypeArgumentsClass, | 127 kTypeArgumentsClass, |
| 128 kTypeArrayClass, | 128 kTypeArrayClass, |
| 129 kInstantiatedTypeArgumentsClass, | 129 kInstantiatedTypeArgumentsClass, |
| 130 kFunctionClass, | 130 kFunctionClass, |
| 131 kFieldClass, | 131 kFieldClass, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // The sentinel is a value that cannot be produced by Dart code. | 203 // The sentinel is a value that cannot be produced by Dart code. |
| 204 // It can be used to mark special values, for example to distinguish | 204 // It can be used to mark special values, for example to distinguish |
| 205 // "uninitialized" fields. | 205 // "uninitialized" fields. |
| 206 static RawInstance* sentinel() { return sentinel_; } | 206 static RawInstance* sentinel() { return sentinel_; } |
| 207 // Value marking that we are transitioning from sentinel, e.g., computing | 207 // Value marking that we are transitioning from sentinel, e.g., computing |
| 208 // a field value. Used to detect circular initialization. | 208 // a field value. Used to detect circular initialization. |
| 209 static RawInstance* transition_sentinel() { return transition_sentinel_; } | 209 static RawInstance* transition_sentinel() { return transition_sentinel_; } |
| 210 | 210 |
| 211 static RawClass* class_class() { return class_class_; } | 211 static RawClass* class_class() { return class_class_; } |
| 212 static RawClass* null_class() { return null_class_; } | 212 static RawClass* null_class() { return null_class_; } |
| 213 static RawClass* var_class() { return var_class_; } | 213 static RawClass* dynamic_class() { return dynamic_class_; } |
| 214 static RawClass* void_class() { return void_class_; } | 214 static RawClass* void_class() { return void_class_; } |
| 215 static RawClass* unresolved_class_class() { return unresolved_class_class_; } | 215 static RawClass* unresolved_class_class() { return unresolved_class_class_; } |
| 216 static RawClass* parameterized_type_class() { | 216 static RawClass* parameterized_type_class() { |
| 217 return parameterized_type_class_; | 217 return parameterized_type_class_; |
| 218 } | 218 } |
| 219 static RawClass* type_parameter_class() { return type_parameter_class_; } | 219 static RawClass* type_parameter_class() { return type_parameter_class_; } |
| 220 static RawClass* instantiated_type_class() { | 220 static RawClass* instantiated_type_class() { |
| 221 return instantiated_type_class_; | 221 return instantiated_type_class_; |
| 222 } | 222 } |
| 223 static RawClass* type_arguments_class() { return type_arguments_class_; } | 223 static RawClass* type_arguments_class() { return type_arguments_class_; } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 static cpp_vtable handle_vtable_; | 304 static cpp_vtable handle_vtable_; |
| 305 | 305 |
| 306 // The static values below are singletons shared between the different | 306 // The static values below are singletons shared between the different |
| 307 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_. | 307 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_. |
| 308 static RawObject* null_; | 308 static RawObject* null_; |
| 309 static RawInstance* sentinel_; | 309 static RawInstance* sentinel_; |
| 310 static RawInstance* transition_sentinel_; | 310 static RawInstance* transition_sentinel_; |
| 311 | 311 |
| 312 static RawClass* class_class_; // Class of the Class vm object. | 312 static RawClass* class_class_; // Class of the Class vm object. |
| 313 static RawClass* null_class_; // Class of the null object. | 313 static RawClass* null_class_; // Class of the null object. |
| 314 static RawClass* var_class_; // Class of the 'var' type. | 314 static RawClass* dynamic_class_; // Class of the 'Dynamic' type. |
| 315 static RawClass* void_class_; // Class of the 'void' type. | 315 static RawClass* void_class_; // Class of the 'void' type. |
| 316 static RawClass* unresolved_class_class_; // Class of UnresolvedClass. | 316 static RawClass* unresolved_class_class_; // Class of UnresolvedClass. |
| 317 static RawClass* parameterized_type_class_; // Class of ParameterizedType. | 317 static RawClass* parameterized_type_class_; // Class of ParameterizedType. |
| 318 static RawClass* type_parameter_class_; // Class of TypeParameter vm object. | 318 static RawClass* type_parameter_class_; // Class of TypeParameter vm object. |
| 319 static RawClass* instantiated_type_class_; // Class of InstantiatedType. | 319 static RawClass* instantiated_type_class_; // Class of InstantiatedType. |
| 320 static RawClass* type_arguments_class_; // Class of TypeArguments vm object. | 320 static RawClass* type_arguments_class_; // Class of TypeArguments vm object. |
| 321 static RawClass* type_array_class_; // Class of the TypeArray vm object. | 321 static RawClass* type_array_class_; // Class of the TypeArray vm object. |
| 322 static RawClass* instantiated_type_arguments_class_; // Class of Inst..ments. | 322 static RawClass* instantiated_type_arguments_class_; // Class of Inst..ments. |
| 323 static RawClass* function_class_; // Class of the Function vm object. | 323 static RawClass* function_class_; // Class of the Function vm object. |
| 324 static RawClass* field_class_; // Class of the Field vm object. | 324 static RawClass* field_class_; // Class of the Field vm object. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 RawArray* functions_cache() const { return raw_ptr()->functions_cache_; } | 460 RawArray* functions_cache() const { return raw_ptr()->functions_cache_; } |
| 461 void set_functions_cache(const Array& value) const; | 461 void set_functions_cache(const Array& value) const; |
| 462 | 462 |
| 463 static intptr_t functions_cache_offset() { | 463 static intptr_t functions_cache_offset() { |
| 464 return OFFSET_OF(RawClass, functions_cache_); | 464 return OFFSET_OF(RawClass, functions_cache_); |
| 465 } | 465 } |
| 466 | 466 |
| 467 // Check if this class represents the class of null. | 467 // Check if this class represents the class of null. |
| 468 bool IsNullClass() const { return raw() == Object::null_class(); } | 468 bool IsNullClass() const { return raw() == Object::null_class(); } |
| 469 | 469 |
| 470 // Check if this class represents the 'var' class. | 470 // Check if this class represents the 'Dynamic' class. |
| 471 bool IsVarClass() const { return raw() == Object::var_class(); } | 471 bool IsDynamicClass() const { return raw() == Object::dynamic_class(); } |
| 472 | 472 |
| 473 // Check if this class represents the 'void' class. | 473 // Check if this class represents the 'void' class. |
| 474 bool IsVoidClass() const { return raw() == Object::void_class(); } | 474 bool IsVoidClass() const { return raw() == Object::void_class(); } |
| 475 | 475 |
| 476 // Check if this class represents the 'Object' class. | 476 // Check if this class represents the 'Object' class. |
| 477 bool IsObjectClass() const; | 477 bool IsObjectClass() const; |
| 478 | 478 |
| 479 // Check if this class represents a signature class. | 479 // Check if this class represents a signature class. |
| 480 bool IsSignatureClass() const { | 480 bool IsSignatureClass() const { |
| 481 return signature_function() != Object::null(); | 481 return signature_function() != Object::null(); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 | 692 |
| 693 // The name of this type's class, i.e. without the type argument names of this | 693 // The name of this type's class, i.e. without the type argument names of this |
| 694 // type. | 694 // type. |
| 695 RawString* ClassName() const; | 695 RawString* ClassName() const; |
| 696 | 696 |
| 697 // Check if this type represents the 'null' type. | 697 // Check if this type represents the 'null' type. |
| 698 bool IsNullType() const { | 698 bool IsNullType() const { |
| 699 return HasResolvedTypeClass() && (type_class() == Object::null_class()); | 699 return HasResolvedTypeClass() && (type_class() == Object::null_class()); |
| 700 } | 700 } |
| 701 | 701 |
| 702 // Check if this type represents the 'var' type. | 702 // Check if this type represents the 'Dynamic' type. |
| 703 bool IsVarType() const { | 703 bool IsDynamicType() const { |
| 704 return HasResolvedTypeClass() && (type_class() == Object::var_class()); | 704 return HasResolvedTypeClass() && (type_class() == Object::dynamic_class()); |
| 705 } | 705 } |
| 706 | 706 |
| 707 // Check if this type represents the 'void' type. | 707 // Check if this type represents the 'void' type. |
| 708 bool IsVoidType() const { | 708 bool IsVoidType() const { |
| 709 return HasResolvedTypeClass() && (type_class() == Object::void_class()); | 709 return HasResolvedTypeClass() && (type_class() == Object::void_class()); |
| 710 } | 710 } |
| 711 | 711 |
| 712 // Check if this type represents the 'bool' interface. | 712 // Check if this type represents the 'bool' interface. |
| 713 bool IsBoolInterface() const; | 713 bool IsBoolInterface() const; |
| 714 | 714 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 745 } | 745 } |
| 746 | 746 |
| 747 // Check the assignability relationship. | 747 // Check the assignability relationship. |
| 748 bool IsAssignableTo(const Type& dst) const { | 748 bool IsAssignableTo(const Type& dst) const { |
| 749 return Test(kIsAssignableTo, dst); | 749 return Test(kIsAssignableTo, dst); |
| 750 } | 750 } |
| 751 | 751 |
| 752 // The type of the literal 'null'. | 752 // The type of the literal 'null'. |
| 753 static RawType* NullType(); | 753 static RawType* NullType(); |
| 754 | 754 |
| 755 // The 'var' type. | 755 // The 'Dynamic' type. |
| 756 static RawType* VarType(); | 756 static RawType* DynamicType(); |
| 757 | 757 |
| 758 // The 'void' type. | 758 // The 'void' type. |
| 759 static RawType* VoidType(); | 759 static RawType* VoidType(); |
| 760 | 760 |
| 761 // The 'Object' type. | 761 // The 'Object' type. |
| 762 static RawType* ObjectType(); | 762 static RawType* ObjectType(); |
| 763 | 763 |
| 764 // The 'bool' interface type. | 764 // The 'bool' interface type. |
| 765 static RawType* BoolInterface(); | 765 static RawType* BoolInterface(); |
| 766 | 766 |
| (...skipping 2201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2968 } | 2968 } |
| 2969 | 2969 |
| 2970 | 2970 |
| 2971 void Context::SetAt(intptr_t index, const Instance& value) const { | 2971 void Context::SetAt(intptr_t index, const Instance& value) const { |
| 2972 StorePointer(InstanceAddr(index), value.raw()); | 2972 StorePointer(InstanceAddr(index), value.raw()); |
| 2973 } | 2973 } |
| 2974 | 2974 |
| 2975 } // namespace dart | 2975 } // namespace dart |
| 2976 | 2976 |
| 2977 #endif // VM_OBJECT_H_ | 2977 #endif // VM_OBJECT_H_ |
| OLD | NEW |