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_RAW_OBJECT_H_ | 5 #ifndef VM_RAW_OBJECT_H_ |
6 #define VM_RAW_OBJECT_H_ | 6 #define VM_RAW_OBJECT_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/atomic.h" | 9 #include "vm/atomic.h" |
10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 V(SubtypeTestCache) \ | 45 V(SubtypeTestCache) \ |
46 V(Error) \ | 46 V(Error) \ |
47 V(ApiError) \ | 47 V(ApiError) \ |
48 V(LanguageError) \ | 48 V(LanguageError) \ |
49 V(UnhandledException) \ | 49 V(UnhandledException) \ |
50 V(UnwindError) \ | 50 V(UnwindError) \ |
51 V(Instance) \ | 51 V(Instance) \ |
52 V(LibraryPrefix) \ | 52 V(LibraryPrefix) \ |
53 V(AbstractType) \ | 53 V(AbstractType) \ |
54 V(Type) \ | 54 V(Type) \ |
55 V(FunctionType) \ | |
56 V(TypeRef) \ | 55 V(TypeRef) \ |
57 V(TypeParameter) \ | 56 V(TypeParameter) \ |
58 V(BoundedType) \ | 57 V(BoundedType) \ |
59 V(MixinAppType) \ | 58 V(MixinAppType) \ |
60 V(Closure) \ | 59 V(Closure) \ |
61 V(Number) \ | 60 V(Number) \ |
62 V(Integer) \ | 61 V(Integer) \ |
63 V(Smi) \ | 62 V(Smi) \ |
64 V(Mint) \ | 63 V(Mint) \ |
65 V(Bigint) \ | 64 V(Bigint) \ |
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 | 860 |
862 class RawClosureData : public RawObject { | 861 class RawClosureData : public RawObject { |
863 private: | 862 private: |
864 RAW_HEAP_OBJECT_IMPLEMENTATION(ClosureData); | 863 RAW_HEAP_OBJECT_IMPLEMENTATION(ClosureData); |
865 | 864 |
866 RawObject** from() { | 865 RawObject** from() { |
867 return reinterpret_cast<RawObject**>(&ptr()->context_scope_); | 866 return reinterpret_cast<RawObject**>(&ptr()->context_scope_); |
868 } | 867 } |
869 RawContextScope* context_scope_; | 868 RawContextScope* context_scope_; |
870 RawFunction* parent_function_; // Enclosing function of this local function. | 869 RawFunction* parent_function_; // Enclosing function of this local function. |
871 RawFunctionType* signature_type_; | 870 RawType* signature_type_; |
872 RawInstance* closure_; // Closure object for static implicit closures. | 871 RawInstance* closure_; // Closure object for static implicit closures. |
873 RawObject** to() { | 872 RawObject** to() { |
874 return reinterpret_cast<RawObject**>(&ptr()->closure_); | 873 return reinterpret_cast<RawObject**>(&ptr()->closure_); |
875 } | 874 } |
876 | 875 |
877 friend class Function; | 876 friend class Function; |
878 }; | 877 }; |
879 | 878 |
880 | 879 |
881 class RawRedirectionData : public RawObject { | 880 class RawRedirectionData : public RawObject { |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1610 | 1609 |
1611 class RawType : public RawAbstractType { | 1610 class RawType : public RawAbstractType { |
1612 private: | 1611 private: |
1613 RAW_HEAP_OBJECT_IMPLEMENTATION(Type); | 1612 RAW_HEAP_OBJECT_IMPLEMENTATION(Type); |
1614 | 1613 |
1615 RawObject** from() { | 1614 RawObject** from() { |
1616 return reinterpret_cast<RawObject**>(&ptr()->type_class_); | 1615 return reinterpret_cast<RawObject**>(&ptr()->type_class_); |
1617 } | 1616 } |
1618 RawObject* type_class_; // Either resolved class or unresolved class. | 1617 RawObject* type_class_; // Either resolved class or unresolved class. |
1619 RawTypeArguments* arguments_; | 1618 RawTypeArguments* arguments_; |
1620 RawLanguageError* error_; // Error object if type is malformed or malbounded. | 1619 // This type object represents a function type if its signature field is a |
| 1620 // non-null function object. |
| 1621 // If this type is malformed or malbounded, the signature field gets |
| 1622 // overwritten by the error object in order to save space. If the type is a |
| 1623 // function type, its signature is lost, but the message in the error object |
| 1624 // can describe the issue without needing the signature. |
| 1625 union { |
| 1626 RawFunction* signature_; // If not null, this type is a function type. |
| 1627 RawLanguageError* error_; // If not null, type is malformed or malbounded. |
| 1628 } sig_or_err_; |
1621 RawObject** to() { | 1629 RawObject** to() { |
1622 return reinterpret_cast<RawObject**>(&ptr()->error_); | 1630 return reinterpret_cast<RawObject**>(&ptr()->sig_or_err_.error_); |
1623 } | 1631 } |
1624 TokenPosition token_pos_; | 1632 TokenPosition token_pos_; |
1625 int8_t type_state_; | 1633 int8_t type_state_; |
1626 }; | |
1627 | |
1628 | |
1629 class RawFunctionType : public RawAbstractType { | |
1630 private: | |
1631 RAW_HEAP_OBJECT_IMPLEMENTATION(FunctionType); | |
1632 | |
1633 RawObject** from() { | |
1634 return reinterpret_cast<RawObject**>(&ptr()->scope_class_); | |
1635 } | |
1636 RawClass* scope_class_; | |
1637 RawTypeArguments* arguments_; | |
1638 RawFunction* signature_; | |
1639 RawLanguageError* error_; // Error object if type is malformed or malbounded. | |
1640 RawObject** to() { | |
1641 return reinterpret_cast<RawObject**>(&ptr()->error_); | |
1642 } | |
1643 TokenPosition token_pos_; | |
1644 int8_t type_state_; | |
1645 }; | 1634 }; |
1646 | 1635 |
1647 | 1636 |
1648 class RawTypeRef : public RawAbstractType { | 1637 class RawTypeRef : public RawAbstractType { |
1649 private: | 1638 private: |
1650 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeRef); | 1639 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeRef); |
1651 | 1640 |
1652 RawObject** from() { | 1641 RawObject** from() { |
1653 return reinterpret_cast<RawObject**>(&ptr()->type_); | 1642 return reinterpret_cast<RawObject**>(&ptr()->type_); |
1654 } | 1643 } |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2371 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2360 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
2372 kTypedDataInt8ArrayViewCid + 15); | 2361 kTypedDataInt8ArrayViewCid + 15); |
2373 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2362 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
2374 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2363 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
2375 return (kNullCid - kTypedDataInt8ArrayCid); | 2364 return (kNullCid - kTypedDataInt8ArrayCid); |
2376 } | 2365 } |
2377 | 2366 |
2378 } // namespace dart | 2367 } // namespace dart |
2379 | 2368 |
2380 #endif // VM_RAW_OBJECT_H_ | 2369 #endif // VM_RAW_OBJECT_H_ |
OLD | NEW |